sending increment value from jquery to php file with for loop help -


i have loop in jquery

$(document).ready(function() {         for(i=0; i<counter; i++)         {             datacounter = i;             $.ajax({               url: 'file.php',                 datatype: 'json',                 data: datacounter,                 error: function(){                     alert('error loading xml document');                 },                 success: function(data){                     $("#contents").html(data);                   }             });         } }); 

and want bring in datacounter file.php variable , have change each time can different records in mysql in file.php, doing right? how php portion like? know how pass variables php file method if had form, don't have or post form work with. also, variables going change.

can me? thank you!

while don't recommend running ajax query inside of loop, wiling explain data option $.ajax(). ideally, pass object data option, , translated jquery query string each object property name key , value value:

data: {   count: datacounter } 

becomes

?count=1 

in query string of ajax request if datacounter equal 1.

in php access $_get['count'].


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -