Jquery ajaxStart doesnt get triggered

Posted by gnomixa on Stack Overflow See other posts from Stack Overflow or by gnomixa
Published on 2010-02-16T18:37:35Z Indexed on 2010/05/03 23:58 UTC
Read the original article Hit count: 367

Filed under:
|

This code

$("#loading").ajaxStart(function() {
        alert("start");
        $(this).show();
    });

in my mark-up

<div style="text-align:center;"><img id="loading" src="../images/common/loading.gif" alt="" /></div>

Here is the full ajax request:

$.ajax({
        type: "POST",       

        url: "http://localhost/WebServices/Service.asmx/GetResults",

        data: jsonText,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {

            var results = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
            PopulateTree(results);
        },

        error: function(xhr, status, error) {
            var msg = JSON.parse(xhr.responseText);
            alert(msg.Message);


        }
    });

$("#loading").ajaxStart(function() {
        alert("start");
        $(this).show();
    });

    $("#loading").ajaxStop(function() {
        alert("stop");
        $(this).hide();
        $("#st-tree-container").show();

    });

never fires alert "start" even though the gif is shown to rotate. AjaxStop gets triggered as expected. Any ideas why?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ajaxstart