mui.ajax的官方模板为
mui.ajax(Host+'/app/index/newsinfo',{
data:{id:newsId},
dataType:'json',//服务器返回json格式数据
type:'POST',//HTTP请求类型
timeout:20000,//超时时间设置为10秒;
headers:{'Content-Type':'application/json'},
success:function(e){
var totaList = JSON.parse(e);
console.log(e);
},
error:function(xhr,type,errorThrown){
//异常处理;
mui.alert("数据请求失败")
}
})
后台无法获取数据
将该模板修改为
mui.ajax(Host+'/app/index/newsinfo',{
data:{id:newsId},
dataType:'text',//服务器返回json格式数据
type:'POST',//HTTP请求类型
timeout:20000,//超时时间设置为10秒
success:function(e){
var totaList = JSON.parse(e);
console.log(e);
},
error:function(xhr,type,errorThrown){
//异常处理;
mui.alert("数据请求失败")
}
})
php后台则可以打印post数据
传递参数id
后台打印
打印结果
mui.ajax的参数传递全是string类型,我tp3.2的需要转换数据类型。
初学者非喜勿喷!