javascript:
var numbers = [0, 1, 3, 5];
for (let k = 0; k < numbers.length; k++) {
let x = numbers[k]
l = $.ajax({
type: 'GET',
url: 'body.php',
data: {'x': x},
contentType: 'application/json; charset=utf-8',
}).then(function(res) {
$("#products").append(res);
})
}
php:
<?php
session_start();
$x = $_GET['x'];
?>
<h5><?php echo $produkt;?></h5>
And it appends it everytime in different order, for example 0 3 1 5 or 1 5 0 3 etc. but when I add to javascript alert(), it goes in right order every time.