这是我在javascript函数:传递JSON到PHP
function callRemoteService(requestId, sObjectId, bObjectId) {
$.ajax({
url: "../../../serviceRemoteEngine.php",
dataType: "json",
contentType: "application/json",
type: "POST",
timeout: 1000,
data: JSON.stringify({"requestId":requestId,"SOobjectId":sObjectId,"SBobjectId":bObjectId}),
success: function(remoteResponse){
alert(remoteResponse.msg);
}
});
}
这是serviceRemoteEngine.php
:
echo json_encode(array("msg" => $_POST["SOobjectId"]));
的函数调用这些参数:
callRemoteService('remove', 15, 0)
事情是,而不是看到15
在警报消息,null
dis代替。
但是,当我改变PHP文件到:
echo json_encode(array("msg" => "message"));
“消息” 文本显示与JS警报。
为什么?
不太确定我跟着怎么'阵列(“味精” => $ _ POST [“SOobjectId”])'只是一个空值? – JakeGould
错误代码。意外的“:”,如预期的那样... – Sates