Here is my code:
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 file looks like
<? echo "data from mysql"; ?>
I can view the data using alert, but how can I add data to a variable?