Thursday, June 6, 2024
 Popular · Latest · Hot · Upcoming
190
rated 0 times [  194] [ 4]  / answers: 1 / hits: 42105  / 15 Years ago, thu, november 19, 2009, 12:00:00

The folowing script does not wait for $.get to finish loading the page before continuing with the loop:



$.each(data.songs, function(index, val) {
$('#nowartist')
.append('song starting');
$.get(http://localhost/play.php, function(data){
alert('done');
});
});


data is a JSON object



Any ideas or comments will be greatly appreciated.


More From » jquery

 Answers
40
$.ajax({
async: false,
type: 'GET',
url: 'http://localhost/play.php',
success: function(data) {
//callback
}
});

That should do it.


Old docs


2021 docs


[#98278] Sunday, November 15, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
adrianobeds

Total Points: 558
Total Questions: 118
Total Answers: 116

Location: Luxembourg
Member since Tue, Jan 25, 2022
2 Years ago
;