tags:

views:

33

answers:

2

Hi

I had this in jquery version 1.3

// ajax requests would get this method
 $().ajaxStart(function (e)
    {
        $('body').css('cursor', 'progress');
    });

Can you still do this. Every time I look though firebug and put break points these never get run. Do I have to move them now to the ajaxSetup?

+2  A: 

From the docs:

Whenever an Ajax request is about to be sent, jQuery checks whether there are any other outstanding Ajax requests. If none are in progress, jQuery triggers the ajaxStart event. Any and all handlers that have been registered with the .ajaxStart() method are executed at this time.

Could it be that you have an Ajax request in progress?

EDIT: possibly use $(document).ajaxStart too instead of $().ajaxStart, saw this mentioned in the comments on the jQuery site.

orip
+2  A: 

You need to do this in 1.4:

$(document).ajaxStart(function (e) {
    $('body').css('cursor', 'progress');
});

Pre 1.4 $() was a jQuery set containing document, now it is actually an empty set...so there's no element to bind the ajaxStart event to, you need to explicitly put document in there now. You can find a full list of breaking changes in 1.4 here.

Nick Craver
Ya just tired that. That does the trick. Any reason why?
chobo2
@chobo2 - Updated the answer to add a bit more context
Nick Craver
Hmm interesting. One more question how would I put ajaxStart in the ajax setup?
chobo2
@chobo2 - Same way, just `$(document).ajaxStart()`, or shorter: `$(document.body).ajaxStart(function() { $(this).css('cursor', 'progress'); });`
Nick Craver
Sorry I meant in $.AjaxSetup()
chobo2
@chobo2 - Oh that's the same: http://api.jquery.com/jQuery.ajaxSetup/
Nick Craver