Looping Through The Url In An Ajax Call In Jquery
So I recently asked a question concerning looping through data in a json file from an asynchronous AJAX call in jquery that uses callback functions (Looping through AJAX and callba
Solution 1:
$.each(myURL,function(i,url){
hmm(url,function(result) {
$.each(result.test.msgOne,function(i,v){
document.write(v);
document.write('<br>');
});
});
});
And in your function -
functionhmm(url,callback) {
$.ajax({
url : url,
dataType: 'json',
success: function(response){
callback(response);
}
});
}
Solution 2:
Try this
for(var k=0,len=myURL.length; k<len; k++)
$.ajax({
url : myURL[k++], //<<<---Want to loop through this arraydataType: 'json',
success: function(response){
callback(response);
}
});
}
Post a Comment for "Looping Through The Url In An Ajax Call In Jquery"