function publish()
{
var title = document.getElementById('postTitle').innerHTML;
var content = document.getElementById('textarea').innerHTML;
mui.ajax('http://campus.ciqufu.com/user/post', {
data: {
"title": 'title',
"content": 'content'
},
type: 'post',
timeout: 10000,
success: function(data) {
mui.toast(data);
},
error: function(xhr, type, errorThrown) {
mui.toast('发送超时');
}
});
}
返回的错误
Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers.
但是我服务器后台已经设置了
header("Access-Control-Allow-Origin:*");
请求前辈分析下
1 个回复
王者地带 - 5+混合APP开发教程网 | http://www.html5-app.com | 咨询QQ: 2564034335
跨域问题, 试下这个
header('Content-type:text/json');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Credentials',true);
header('Access-Control-Allow-Methods', 'POST, GET');
header('Access-Control-Allow-Headers','x-requested-with,content-type');