我的js侧面看像这样
$.ajax({
type:"POST",
data: {data:'abc'},
url: "http://example.com/",
success: function(result){
console.log(result);
}
});
在我的PHP我做
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
$user_id = $_POST['data'];
echo $user_id;
但我的成绩在控制台返回空白。
But my result in console returned blank.
要调试,我尝试回声'123'
,阿贾克斯也收到了123的价值,出了什么问题吗?
To debug, I try to echo '123'
, the ajax did received the value of 123, what has gone wrong here?
数据也应在报价
$.ajax({
type:"POST",
data: {'data':'abc'},
crossDomain: false,
url: "http://example.com/",
success: function(result){
console.log(result);
}
});