代码如下
lostDelete:function(lostId){
var a;
var keywords={"tokenId":sessionStorage.getItem("tokenIdSave"),
"userId":sessionStorage.getItem("userIdSave"),
"id":location.hash.substr(1)};
console.log(keywords);
$.ajax({
type:"DELETE",//http://192.168.0.88:8080
url:"http://192.168.0.88:8080/api/app/losts/"+location.hash.substr(1)+"/delete",
data:keywords,
contentType:"application/json",
dataType:"json",
async:false,
success: function (res) {
console.log(res)
},
error: function () {
console.log("error")
}
});
}
我的代码就是这样 而且服务器端加了允许跨域的设置了,但是还是这样报错
jquery.js:9631 XMLHttpRequest cannot load http://192.168.0.88:8080/api/app/losts/cf6535f53b674c8e96105f7536a167b2/delete. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8020' is therefore not allowed access.
send @ jquery.js:9631
ajax @ jquery.js:9176
lostDelete @ lostsXiangxi.html:542
(anonymous) @ lostsXiangxi.html:683
dispatch @ jquery.js:4641
jQuery.event.add.elemData.handle @ jquery.js:4309
lostsXiangxi.html:555 error
求解答
请问楼主解决了吗?我也遇到了~~不过是404的错误
回复 @思卖偶:404是你们服务器的问题你可以看下http协议404的含义版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。