2***@qq.com
2***@qq.com
  • 发布:2017-12-03 11:06
  • 更新:2017-12-03 16:52
  • 阅读:1206

关于MUI的ajax

分类:MUI
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:*");

请求前辈分析下

2017-12-03 11:06 负责人:无 分享
已邀请:
王者地带

王者地带 - 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');

该问题目前已经被锁定, 无法添加新回复