Ajax loading order test
Checks to see if the local variable in an Ajax call retains its value when the Ajax call has completed as it may be in a different order to when it was called.
by Terry King
HTML
<div id="comments"></div>
JavaScript
function loadComments(ind) {
$.ajax({
cache:false,
url: "/echo/html/",
type: "POST",
data: {html:"comments"+ind+"<br>",delay:0}
}).done(function (data) {
$("#comments").append(ind+" "+data)
});
}
loadComments(0)
loadComments(1)
loadComments(2)
loadComments(3)
loadComments(4)
loadComments(5)
loadComments(6)