开发者社区> 问答> 正文

浏览器用jq发送put/delete请求怎么解决?报错

代码如下

        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

求解答

展开
收起
爱吃鱼的程序员 2020-06-08 15:56:20 671 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    请问楼主解决了吗?我也遇到了~~不过是404的错误

    回复 @思卖偶:404是你们服务器的问题你可以看下http协议404的含义
    2020-06-08 15:56:40
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
WEB浏览器中即将发生的安全变化 立即下载
基于浏览器的实时构建探索之路 立即下载
基于浏览器的实时构建探索之路--玄寂 立即下载