CORS-ISSUE:在ajax post request

时间:2017-09-20 12:33:08

标签: jquery json ajax cors

我正在尝试使用jquery ajax调用发送数据,我收到错误XMLHttpRequest无法加载http://localhost:8080/CI-REST/rae/comm/FBInfo。对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许原点“http://localhost”访问。

 $.ajax({
                        type : "POST",
                        url: "http://localhost:8080/CI-REST/rae/comm/FBInfo",
                        data : JSON.stringify(userInformation),
                        dataType : "json",
                        contentType: "application/json; charset=utf-8",
                        headers : {
                            'Access-Control-Allow-Origin':'http://localhost/',
                        },
                        crossDomain : true,
                        xhrFields: {
                        withCredentials: true
                        },
                        success : function (result) {
                            console.log(result);
                        }});
                    }
                    }

当我在不使用json.stringify的情况下进行调用时,它在jersy中击中了我的post方法,但是对象在那里作为null。但是当我使用JSON.stringify发送数据时,我在浏览器中出现了cors错误[标题的附加图像]

0 个答案:

没有答案
相关问题