我有一個jQuery的Ajax POST請求去一個PHP網站與一些數據添加在_POST數組。 我無法弄清楚爲什麼在Ajax響應中,我好像在我的JSON響應之前將_POST數組返回給我。我想要的只是下面回覆中的第二行。爲什麼我的jQuery Ajax響應首先包含post數組?
$.ajax({
type: "POST",
url: "site.php",
data: { requestType : 'someType', table : 'someTable' },
success: function(data){
alert(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown); //or whatever
}
});
響應:
array(2) { ["requestType"]=> string(6) "someType" ["table"]=> string(17) "someTable" }
[{"User":1,"User":"xxx","Pd":"xxx","Name":"xxx","Age":xx,"Occupation":"xxx","Description":"xxx"}]
的PHP
$result = $stmt->execute();
//put the results in to the $result variable
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
array_push($result_array, $row);
}
echo json_encode($result_array);
mmmmm看看你打印出來的文件是什麼,因爲這不是JQuery的東西。 – BlaShadow
向我們展示您的php代碼。你如何回覆回覆? – Arlind