AJAX REQUEST WITH IN AJAX REQUEST jquery -
$.ajax({ type: 'post', url: searchpage, datatype: "json", data: { id: id }, success: function(data) { var id1 = []; for(var = 0; < data.length; i++){ id1 .push({ id1 : data[i].id }); $("#printtdownername").text(data[i].fullname); $("#printtdownerbday").text(data[i].bday); $("#printtdownerage").text(data[i].age); } $.ajax({ type: 'post', url: 'searchpage1', datatype: "json", data: { id1: json.stringify(id1) }, success: function(data) { }, error: function(data) {} }); }, error: function(data) { } });
in project need send ajax request on specific event , when request successful want send ajax request. right working ok since database small.
my question have negative effect if example have big database. if not practice how should deal scenario. need id1 response of first ajax in order send second ajax.
$.ajax({ type: 'post', url: searchpage, datatype: "json", data: { id: id }, success: function(data) { var id1 = []; for(var = 0; < data.length; i++){ id1 .push({ id1 : data[i].id }); $.ajax({ type: 'post', url: 'searchpage1', datatype: "json", data: { id1: json.stringify(id1) }, success: function(data) { }, error: function(data) {} }); } }, error: function(data) { } });
try this. think might helpful you
here working example : example
for avoid unnecessary requests call after loop.
Comments
Post a Comment