$(document).ready(function (){ var n = 9; for(var i=0;i<n;i++){ var div = document.createElement('div'); div.className = "d5"; div.id=i+1; document.getElementById('container').appendChild(div); $.ajax({ url: 'myapi.php', //the script to call to get data data: "", //you can insert url argumnets here to pass to api.php for example "id=5&parent=6" dataType: 'json', //data format success: function(data) //on recieve of reply { var Name = data[2]; //get id //var vname = data[1]; //get name $('#'+div.id).html(""+Name); } }); } });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)