$(document).ready(function () { $('input:button').click(function() { if($('#fileName').val() == '') { $('#result').html('<span>Please provide a file name.</span>'); return; } $.ajax({ url: $('#fileName').val(), method: 'get', success: function(data) { $('#result').html(data); }
error: function()
{
$('#result').html('<span>An error occured.</span>');
} }); }); $('#result').ajaxError(function() { $('#result').html('<span>An error occured.</span>'); }) });