使用该方法发现here,我收集表格值,并使用下面的代码张贴:JSON格式
$.ajax({
type: "POST",
url: "http://"+document.domain+"/SimplaAdmin/includes/rpc.php",
data: { data:postdata, method: 'addSite'},
dataType: "json",
.......
发布的数据是:
data:{
"textfield": ["",""],
"dropdown": ["option1","option1"],
"siteTitle":"this is the site title",
"siteKey":"",
"siteurl":"",
"address1":"",
"address2":"",
"address3":"",
"landline":"",
"method":"addSite",
"small-input":"",
"medium-input":"",
"large-input":""
}
然后我试图让价值siteTitle
使用:
$data = $_POST['data'];
$obj=json_decode($data) ;
$title = $obj->{'siteTitle'};
但它不起作用,在哪里我的想法有缺陷吗?
尝试json.stringify - Google-ify it;) – PhD