I want to call webservice with multiple data's at a time.So here i have used ajax with in the for loop for sending the reguest one by one.But in my below code, only the first value of the array is passed due to the asynchronous ajax call.
How can I pass each iteration of the array to the callback function, aside from running the ajax call synchronously?
The following is my loop structure.I hope any body will help me,thanks in advance.
var jsonarray=new Array();
for (var i = 0; i < results.rows.length; i++)
{
jsonarray.push(results.rows.item(i));
$.ajax
({
url:www.webservice.com,
type:'POST',
dataType:'jsonp',
contentType: "application/json; charset=utf-8",
timeout:1000000,
data: {data: JSON.stringify(jsonarray)},
success:function(data)
{
...
},
error:function()
{
}
});
}