Code:
$(function(){
var Name = [];
for($i=1; $i<16; $i++) {
var id = $i;
$.post("./index.php", {
record : id
}, function(data){
Name.push(data);
});
}
alert(Name);
});
data return result as <a href="#"><img src="./name.jpg"></a>
Tell me please why data not add in array?
The
post requestis an async method .You will hit the alert even before you hit the success function.