我有以下json,我通过AJAX发送,但在服务器端json_decode返回一个空数组。我也发送不同的值,在这种情况下,它工作正常。我检查了这个link,这是一个有效的JSON。
[
{
"name": "bettype",
"value": "All"
},
{
"name": "bookies",
"value": "Interwetten"
},
{
"name": "sporttype",
"value": "Soccer"
},
{
"name": "team1",
"value": "Braunschweig"
},
{
"name": "team2",
"value": "Bayern Munich"
},
{
"name": "league",
"value": "Germany DFB Cup (90`)"
}
]
更新:
这是服务器端代码:
var_dump((stripslashes($_GET['data']));
var_dump(json_decode(stripslashes($_GET['data'])));
这是输出:
string(244) "[{"name":"bettype","value":"All"},{"name":"bookies","value":"Interwetten"},{"name":"sporttype","value":"Soccer"},{"name":"team1","value":"Braunschweig"},{"name":"team2","value":"Bayern Munich"},{"name":"league","value":"Germany DFB Cup (90�)"}]" NULL