我想通過PHP上的array()
來自JavaScript,但PHP沒有收到任何東西。它始終將$str
設置爲""
。爲什麼?從JavaScript傳遞數組到PHP
的JavaScript
var ArrayPassedID = [];
function pass(){
$.ajax({
url: 'http://mysite/index2.php?task=getPassed',
type:'get',
dataType:'json',
data: {id: JSON.stringify(ArrayPassedID)},
async: false,
success: function(response){
ArrayPassedID.push(response.id);
}
....
PHP
$str = "";
if(!empty($_POST["id"])){
$id = $_POST["id"];
$id = json_decode($id,true);
$str = implode(",",$id);
}
$data = query(SELECT id, response FROM `conversation` WHERE id not in ('".$str ."'));
$values = array();
$values['id'] = $data['id'];
$values['response'] = $data['response'];
return json_encode($values);
,如果你改變'數據:JSON.stringify({ID:ArrayPassedID});' – DontVoteMeDown
你的Ajax:'類型: '得到','和你PHP'$ _POST' ...改變一個或另一個,看看會發生什麼:) – tymeJV
我see..let我試試.. :) – Snippet