收到$ _ POST变量我在做,看起来一个Ajax请求喜欢从jQuery的Ajax请求
var object = JSON.stringify(object);
// var url = "http://"+baseURL +"/"+endpoint;
$.ajax({
contentType: "application/json",
dataType: 'json',
type:type,
data:object,
url:endpoint,
success:function(data){
if (typeof callback == "function"){
alert(data);
}
},
error: function (xhr, textStatus, errorThrown) {
console.log(xhr.statusText);
console.log(xhr.responseText);
console.log(xhr.status);
console.log(errorThrown);
}
});
其中var=object
是一个字符串化JSON objectby这使得它成为Ajax请求的时间。在PHP端,我试图做
<?php
echo ($_POST['object']);
exit;
?>
赶上变量和我的成功回调函数提醒数据,“空”。我究竟做错了什么?
感谢, 亚历克斯
这不是POST。 –
“type”的确切位置在哪里?如果这不是'POST',那么你不会做一个职位... –
print_r($ _ POST); –