I think I'm doing a classical ajax script which should be fairly easy for the people who have worked with it.
Alright the idea is to call a page from jquery ajax which calculates and loops through some data. I want the page to respond back to the javascript whenever it got 1 row calculated. The jquery should then populate a div row for row. Meaning it should NOT wait for all rows to complete, but just take one row at a time.
Does it make sense? The problem should be well-known, but sorry for my bad explanation. My code so far:
Jquery page:
$(document).ready(function() {
loadCityFriends();
});
function loadCityFriends() {
$.ajax({
url: 'cityfriends.php',
success: function(data) {
$("#cityfriends").append(data);
}
});
}
And cityfriends.php (the page calculating):
foreach bla bla bla
print '{"fbid": "'.$friend["id"].'", "img": "'.$friend["picture"].'"}';
My code wait until cityfriends.php are done looping and then populates the div.