Is is better and more correct to use jQuery(document).ajaxStart(function(){$('#content').html('Loading...')})? – BinyaminJan 12 '11 at 20:09

1

@Binyamin - You can do that yes, it has a different purpose though, that runs every time an AJAX request batch starts, rather than when this one starts...if that's what you're after, certainly that's fine, and you can slim it down to $('#content').ajaxStart(function() { $(this).html('Loading...'); }); :) – Nick Craver♦Jan 12 '11 at 20:34

When data is retrieved from remote servers (which is only possible using the script or jsonp data types), the operation is performed using a tag rather than an XMLHttpRequest object. In this case, no XMLHttpRequest object is returned from $.ajax(), and the XMLHttpRequest object and the textStatus arguments passed to the handler functions such as beforeSend will be undefined. The error callback will never be fired for JSONP requests.