1
我有一个工作的jQuery程序,谈论一个服务器上的PHP程序,我正在从PHP到前端移动JSON数据是没有问题的。传递JSON与jQuery的
现在我需要JSON数据发送到我的后端PHP服务器
当我使用这个语法
'$.post("../wrk/filterquest.php",{
"yesTransactionId" : "yesTransactionId",
"oproductOfferId" : "productOfferId"
},
function ...'
我的PHP接收它。我检查,列出测试文件PHP构建
[email protected] [~/public_html/wrk]# cat test
filterquestPOST=array (
yesTransactionId => yesTransactionId,
oproductOfferId => productOfferId,
)
GET=array (
)
然而,当我宣布一个字符串,并同一JSON手动加载到其中
'poststr = " {\"yesTransactionId\" : \"yesTransactionId\", \"oproductOfferId\" : \"productOfferId\"}";'
我并尝试发送它
$.post("../wrk/filterquest.php",poststr,
function...
我的php没有得到它
[email protected] [~/public_html/wrk]# cat test
filterquestPOST=array (
)
GET=array (
)
如果你关心写我用它来跟踪貌似
'<?php
try
{
// Debug
$debu = "> test";
exec($debu);
$lang_str = var_export($_POST,true);
$debu = "echo 'filterquestPOST=". $lang_str ."' >test";
exec($debu);
$lang_str = var_export($_GET,true);
$debu = "echo 'GET=". $lang_str ."' >>test";
exec($debu);
//Open database connection ....'
测试文件的PHP那么什么是语法我需要把JSON字符串中的,并得到该字符串变量到后端服务器? (注意:我可以建立一个javascript数组,并使用JSON.stringify加载多串,但我甚至无法得到这个简单的字符串移动。
感谢
JSON是不是字符串,但poststr是一个字符串。 – inarilo