json - Ajax stuck when try call second time -
my ajax code doesn't want answer again when ajax code run 1 time.
my code:
$.ajax({ type : "post", url : "scriptnext.php", datatype: 'json', data : {aid: actid}, success : function(retour){ $("#actionall").fadeout(function() { $("#actionall").html(retour.message1); $("#actionall").fadein(); }); $("#btnnext").fadeout(function() { $("#btnnext").html(retour.message2); $("#btnnext").fadein(); }); }, error: function(xhr, ajaxoptions, thrownerror){ alert("erreur appel page jquery !"); alert(xhr.status); alert(thrownerror); } }); code call ajax function:
<div id=actionall class=result> butter </div> <div class=item id=btnnext> <a href=# class=plusun actionid=1 attribuid=actionall >next </div> the called function (scriptnext.php) return data (sugar) first time, but, after update href item field, can't called second time - nothing happening.
here approach take,
a. check if ajax call in progress , abort before calling same method again.
b. in order that, follow code structure i've provided below,
var getdataajaxcall;//declare variable function getdata(){ //check if previous call still pending , abort before making new //one. if (getdataajaxcall&& getdataajaxcall.readystate != 4) getdataajaxcall.abort(); getdataajaxcall = $.ajax({ type : "post", url : "scriptnext.php", datatype: 'json', data : {aid: actid}, success : function(retour){ $("#actionall").fadeout(function() { $("#actionall").html(retour.message1); $("#actionall").fadein(); }); $("#btnnext").fadeout(function() { $("#btnnext").html(retour.message2); $("#btnnext").fadein(); }); }, error: function(xhr, ajaxoptions, thrownerror){ if (ajaxoptions!= 'abort') { alert("erreur appel page jquery !"); alert(xhr.status); alert(thrownerror); } } }); }
Comments
Post a Comment