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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -