jquery - ajax call not reset old data -
i using ajax in website, working fine not success data on next call, mean if on first call, data 1 , 0 , on second call data 0 , 1, showing on 2nd call 1, 0, 0, 1
function checkform(){ var userid = $("#userid").val(); var email = $("#email").val(); $.ajax({ url:path+"ajax_getpass.php", data:{userid : userid, email : email}, cache:'false', type:'post', datatype:"json", success: function(data_send){ $(document).ajaxcomplete(function(event, request) { //data = $.parsejson(data); alert(data_send.email); alert(data_send.userid); }); } }); return false; }
please tell me wrong.
this because add more , more functions ajaxcomplete()
every time ajax request successful. when success code called first time, 1 function called ajaxcomplete()
. next request, function added, 2 functions called.
use code instead:
$.ajax({ url:path+"ajax_getpass.php", data:{userid : userid, email : email}, cache:'false', type:'post', datatype:"json", success: function(data_send){ alert(data_send.email); alert(data_send.userid); } });
you need $.ajaxcomplete()
when want respond ajax requests sent other part of code (i.e. in places can't specify success function).
think of kind of global "success" function.
Comments
Post a Comment