views:

1025

answers:

2

Hi ... can't seem to get the ajaxSend and Stop to work... These are global variables no? .. but i should be able to use like this... but i never get an alert??

I wanted to use these events to display a ajax animation.. although in my code i wish to position the ajax animation depending what i am doing an what element it is..

            $.ajax({
            type: "POST",
            url: "MyService.aspx/TestMe",
            data: JSON.stringify(data),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            ajaxSend: function(r,s) {
                alert('i am starting');
            }
            ,
            ajaxStop: function(r,s) {
                alert('i am stopping');
            }
            ,
            success: function(msg) {
            }
        });
+1  A: 

So you don't use this functionality properly. ajaxStop, ajaxComplete and etc. is not a parameters of $.ajax function. Let say you have an ajax icon which you want to remove on request completion.

 $("#ajax_icon").ajaxStop(function(){
   $(this).hide();
 });

You have a good reference here

PS. With other function is the same.

Artem Barger
A: 

Those are globals, and the way I typically see them assigned is:

$('element').ajaxStart(function() {
 ... do something ...
}

Assigning them to a specific ajax request, I'm not sure if that will do what you want it to do.

altCognito