我已将此变量传递给php页面
type: 'POST',
url: url',
data: "id="+id+"&nowrole="+role+"&last="+last+"&title="+title+"&devlopdes="+devlopdes
有时候,第一组值是
id=1234
role=staff
last=45
title=check page
developdes= view this
http://hibihi.com/index.php?act=view&id=1
http://hibihi.com/index.php?act=add&shipperid=1
在php页面
检索id =“1http://hibihi.com/index.php?act = add”不检索传递'id'值
有时候,第二组值是
id=1234
role=staff
last=45
title=check page
developdes= view this
http://hibihi.com/index.php?act=view
http://hibihi.com/index.php?act=add&shipperid=1
检索正确的id = 1234值。
答案 0 :(得分:0)
如果您正在使用对象,则可以在javascript中使用此代码:
var obj = {};
obj[id] = "1234";
obj[role] = "staff";
obj[last] = "45";
obj[title] = "check page";
obj[developdes] = "view this";
obj[http1] = "http://hibihi.com/index.php?act=view&id=1";
obj[http2] = http://hibihi.com/index.php?act=add&shipperid=1";
然后
type: 'POST',
url: url',
data: JSON.stringify(obj)
对于你的PHP
$json = jsondecode($_POST[data]);
$id = $json->{'id'};