var myArray = JSON.parse(localStorage.myArray);
console.log(myArray);
var data = JSON.stringify(myArray);
$.ajax({
type: 'POST',
url: 'Путь к моему файлу/page-izbranni.php',
dataType: 'json',
cache: false,
data: {checks: data},
success: function(data) {
alert(data)
}
});
<?php $izzz = json_decode($_POST['checks']); ?>
<p><?php echo $izzz; ?></p>
<!DOCTYPE HTML>
<html>
</head>
<body>
<div id="answerPlace"></div>
</body>
<script type="text/javascript" src ="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
var myArray = [2, 23, 54, 79, 27, 99, 14];
var url = 'http://page-izbranni.php';
var answer;
$(document).ready(function()
{
$.ajax
({
url: url,
data:
{
checks: JSON.stringify(myArray)
},
success: function(response)
{
$('#answerPlace').children().remove();
$('#answerPlace').append(response);
},
error: function(error)
{
console.log('Ошибка');
console.log(error);
}
});
});
</script>
</html>
if(isset($_REQUEST['checks']))
{
echo "<pre>";
print_r(json_decode($_REQUEST['checks']));
echo "</pre>";
}
add_action('wp_ajax_nopriv_ajaxmass', 'true_get_ajax_mas');
$agro_id = implode(", ", json_decode($_REQUEST["checks"]));
$.ajax({
url : 'http://' + location.host + '/wp-admin/admin-ajax.php',
data: { action: 'ajaxmass', checks: localStorage.myArray
},
success: function (menu) {
$('.content2 .testim').eq(0).html(menu);
$('.izbran').unbind().bind('click', clickOnStar);
console.log(menu);
}
});