1.用ajax请求后台数据,返回信息一直是Request parse error,我以为解析数据的问题,加了dataType:"json"还是同样的错误,不知道还有什么其他的原因。
2.代码如下:
$.ajax({
url:"http://slave.nx96200.cn/feemanager/ordermanager/create_order",
type:"post",
data:{
"accesstoken": token,
"buy": {
"targetid": 131, //券id
"programid": 100000091,
"targettype": 2,
"effectivetime": 1,
"isreorder": 0,
"orderduration":{
"value": 3,
"unit": 2
}
}
},
dataType: "json",
success:function(data){
}
})
接口请求地址没有设置跨域允许, 如果已经设置了允许跨域的话,就看接口的数据格式是什么,可能是 json,也可能是 jsonp,这个相对应的前端要写:
dataType : 'json'
或者dataType : 'jsonp'