php无法接收 mui.ajax 传过来的数据-解答
mui 官方文档 代码示例:如下为通过post方式向某服务器发送鉴权登录的代码片段
mui.ajax('http://server-name/login.php',{
data:{
username:'username',
password:'password'
},
dataType:'json',//服务器返回json格式数据
type:'post',//HTTP请求类型
timeout:10000,//超时时间设置为10秒;
headers:{'Content-Type':'application/json'},
success:function(data){
//服务器返回响应,根据响应结果,分析是否登录成功;
...
},
error:function(xhr,type,errorThrown){
//异常处理;
console.log(type);
}
});
$post[] 所取的值为空。
将 headers:{'Content-Type':'application/json'},
改为
headers:{'Content-Type':'application/x-www-form-urlencoded'},
就可以接收数据了。