ajax - jQuery Multiple .ajaxSuccess, load different functions specifically for each ajaxSuccess -
i need load different functions different ajaxsuccess in 1 page.
i have multiple ajax in 1 page , cannot figure away more specific on ajaxsuccess happen.
at moment using:
$(document).ajaxsuccess(function(){ func1(); }); // ajax1 success => load func1() // ajax 2 success => load func2() // ajax 3 success => load func3()
you can attach separate successs methods each call using
$.ajax({ type : "post", url : "url", data:"{}", contenttype : "application/json; charset=utf-8;", datatype: "json", success : function(response){}, error : function(response){} });
using approach can call specific success method attached each ajax call. don't need bind every call 1 common ajaxsuccess. , if want so, need send kind of id in response call specific function.
e.g
$(document).ajaxsuccess(function(response){ if (response.id==1) func1(); else if (response.id==2) func2();
});
hope helps.
Comments
Post a Comment