您好,客户端请参考以下代码:
api.ajax({ url:'http://xxx.xxx.xxx.xxx/xxx', method: 'post', data: { values:{name: 'devlp', password: '123456'} } },function(ret,err){ if (ret) { api.alert({msg:JSON.stringify(ret)}); } else { api.alert({ msg : ('错误码:'+err.code+';错误信息:'+err.msg+'网络状态码:'+err.statusCode) }); }; });
去除不必要的信息,如header等,header中的content-type可能会导致你的服务器误判客户端提交的数据类型而忽略提交的数据;
php中:$_POST['paramName']方法只能接收Content-Type为application/x-www-form-urlencoded提交的数据,所以你可以将你的ajax请求中的header中的Content-Type改为application/x-www-form-urlencoded或者直接将header字段去掉,APICloud提供的ajax请求中,Content-Type默认就是application/x-www-form-urlencoded的;
如此即可。
|