这是我的代码:
var myVariable = "<div>";
for (i = 1; i < 5; ++i) {
myVariable += '<div class="user' + i + '">';
$.ajax({
type: "POST",
data: "uziv=" + i,
url: "../php/ajax_objednavky.php",
success: function(data){
//alert(data); work well
//$('#content').html(data); work well
myVariable += data; //doesn't work
}
});
myVariable += '</div>';
}
myVariable += "</div>";
$('#myDiv').html(myVariable);
PHP文件看起来像
<? echo "data from mysql"; ?>
我可以使用警报查看数据,但是如何将数据添加到变量中?