javascript - PHP & Jquery Ajax, json, get data in the ajax destination file -
i need send array in php trough ajax different server, trying following. array encoded json_encode : [ {"id":"1","name":"avocado toast tartine","qty":"1","price":"88.00","spec":""}, {"id":"16","name":"add berries","qty":"1","price":"48.00","spec":""} ] so in origin file have: <script> var cart = <?php echo $cart; ?>; //this array above $.ajax({ url: 'https://www.mydestinationurl.com.hk/new/admin/do_lpq_order.php', crossdomain: true, type: 'post', data: cart }).done(function(data) { console.log(data); }); </script> and in destination file have this: <?php switch ($_server['http_origin']) { case 'http://localhost': case 'https://...