$(function(){
$.ajax({
url:'check.php', //api接口地址
data:{
"head": {
"name": "test",
},
"body": {
"age ": "2",
}
},
type:'post', //数据传输方式
dataType:'json',//数据传输格式
cache:false,
success:function(data) {
//执行成功后的回调函数,data为返回的数据
alert(data);
},
error : function() {
alert('error');
}
});
});
新手,求问为什么这个老是显示error,也就是说post不成功?怎么改?后台接收的话用PHP怎么解析这个数据呢?
json格式错误,"test", "2" 后面都不需要 逗号