in jsp page, when user clicks button, ajax call triggered. if user clicks again , again button, last ajax call valid , response considered.
i use:
var lastrequest=null; $('#button').click(function() { if (lastrequest) { lastrequest.abort(); lastrequest = null; } lastrequest = $.ajax({ type: "post", url: "myaction.do", success: function (response) { response= $('<div/>').append(response); } }); }); with firebug, see request aborted, not all. think if ajax call triggered, it's not possible ignore response, it?
edit
if set var in myaction.do , read in success callback, possible have conflict in success callback?
in case, how prevent behaviour?
my experience aborting ajax-calls can pretty random when works.
a workaround i've used once or twice counters:
var lastrequest=null; var started = 0, finished = 0; $('#button').click(function() { ++started; lastrequest = $.ajax({ type: "post", url: "myaction.do", success: function (response) { //only stuff on last active request if(++finished == started) response= $('<div/>').append(response); } }); });
Comments
Post a Comment