一个例子永远是最有帮助的:
// javascript part - use jQuery for example
$.ajax({
url: "your-php-file.php",
data: ['abc','def'] // your array
});
// PHP part your-php-file.php
die($_POST); // you will see the $_POST[data] = array('abc', 'def');
如果你想以相反的方式发送数据,从PHP到JavaScript,添加到你的PHP文件的东西。
echo json_encode (array('data_from_php'));
// and in JS you have a callback on success for querying a php file
$.ajax({
url: "your-php-file.php",
//data: [], // we dont send nothing this time
success: function(data){
console.log(data); // data will be a js array containing a string 'data_from_php'
}
});
AJAX? http://www.devirtuoso.com/2009/07/beginners-guide-to-using-ajax-with-jquery/ –
您必须更改您的问题或将其关闭。描述实际情况,而不是一些模糊的想法。什么中间站点?你想要来回发送什么数据?它是什么应用程序等等。 –