Я конвертирую разделенную запятыми строку идентификаторов и запускаю каждый из них с помощью простого вызова WordPress ajax. Вот так ....
JS
ids = '575,570,579';
var ids_array = ids.split(',');
ids_array.forEach(function(ids_array_item) {
$.ajax({
type : 'POST',
url : 'myurl',
data : {
action : 'get_custom_content',
customid : ids_array_item
},
success : function( response ) {
if (response != '') {
console.log('response : ' + response);
}
}
});
});
PHP
add_action('wp_ajax_get_custom_content', 'get_custom_content');
add_action('wp_ajax_nopriv_get_custom_content', 'get_custom_content');
function get_custom_content() {
$customid = $_POST['customid'];
echo $customid;
die();
}
Я ожидаю получить это обратно ...
response : 575
response : 570
response : 579
Но я получаю это вместо ...
response : 575
response : 579
response : 570
Кто-нибудь имеет представление о том, почему ордер искажается, когда он выполняется через вызов ajax?