ajaxStart only called once

Posted by cmroanirgo on Stack Overflow See other posts from Stack Overflow or by cmroanirgo
Published on 2010-03-22T05:10:54Z Indexed on 2010/03/22 5:21 UTC
Read the original article Hit count: 307

Filed under:
|
|

I'm having trouble with ajaxStart/ajaxStop. In the following code, the ajaxStart/ajaxStop code is only ever called once (the very first time). Any ideas why?

var A_func = function() {
    $.get($(this).attr("href"), function(response) {
        $("#content_inner").replaceWith($("#content_inner", response));
    });
    return false;
 };
 $(function() {
    $("A").live("click", A_func);
    $(document).ajaxStart(function(){$("#loading").show();alert("loading");});
    $(document).ajaxStop(function(){$("#loading").hide();alert("finished");});
 });

Note that the ajax requests themselves work correctly, it's just that the 'loading' icon only shows the once and then never again.

My html is something like:

<body>

<img id="loading" width="12" height="12" src="/images/ajax-loader.gif" style="display:none" alt="loading"/> ...

<div id="content"><div id="content_inner">...</div></div>... </body>

I have also tried using ajaxSend/ajaxComplete and it has the same problem

© Stack Overflow or respective owner

Related posts about jquery-ajax

Related posts about jQuery