Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 状态代码:405方法不允许_Javascript_Jquery_Ajax_Post_Get - Fatal编程技术网

Javascript 状态代码:405方法不允许

Javascript 状态代码:405方法不允许,javascript,jquery,ajax,post,get,Javascript,Jquery,Ajax,Post,Get,我们正在尝试将用户信息发布到服务器。我们正在开发混合应用程序。使用ajax调用,我们将数据发布到服务器。但我们总是遇到错误 错误 我们是这样受审的 jQuery.support.cors = true; $.ajax({ url: 'http://192.168.3.226:2468/MyService.svc/UploadSettlementLine', type: 'POST',

我们正在尝试将用户信息发布到服务器。我们正在开发混合应用程序。使用ajax调用,我们将数据发布到服务器。但我们总是遇到错误 错误

我们是这样受审的

jQuery.support.cors = true;
    $.ajax({
                       url: 'http://192.168.3.226:2468/MyService.svc/UploadSettlementLine',
                       type: 'POST',
                       data: [{"billtocustomerno":"UBG/00816","no":"325/2016/0291/2190","itemnumber":"FG/1072","uom":"ggg","description":"BABYSOFT PJ 150 ML x 6 DOZ","locationcode":"UBUNGO","vehicle":"","resonfornosales":"","allocation":"","unitprice":50847.46,"quantity":1,"vatpercent":18,"amount":50847.46,"discount":0,"linediscount":508.47,"specialdiscount":0,"lineamount":50338.99,"vatamount":9061.02,"includingvat":59400.01,"foc":0,"shortcutdismension1code":"325","postingdate":"2016-01-21 14:18:31","salespersoncode":"MKRT019","focitems":0,"customerpriceGroup":"0","loadingsheetno":"LDUBG/16/0291","vatpostinggroup":"0"}],
                       dataType: 'jsonp',
                       contentType : "application/json;charset=utf-8",
                       success: function(response, textStatus, jqXHR) {
                           debugger;
                         alert("Yay!");
                       },
                       error: function(jqXHR, textStatus, errorThrown){
                           debugger;
                         alert(textStatus, errorThrown);
                      }
                    });
请引导我们。告诉我代码中的错误

如果我们放置dataType:json,我们会得到这个错误

OPTIONS http://192.168.3.226:2468/MyService.svc/UploadSettlementLine 405 (Method Not Allowed) jquery.min.js:4
XMLHttpRequest cannot load http://192.168.3.226:2468/MyService.svc/UploadSettlementLine. Request header field Content-Type is not allowed by Access-Control-Allow-Headers.

您已将数据类型设置为jsonp。。。因此,请求将是一个得到-尽管你“想要”一个职位。。。可能服务器端看到GET并发出错误消息,因为它只接受POST方法。。。甚至连服务器端的外观(发出错误的部分)都不知道,只能speculate@JaromandaX谢谢你的回复。塞弗说代码是由某个人写的。他们说我们发帖子。所以我们试着发帖子。请检查我的更新问题和给我们的指南,但你没有发帖子。。。查看错误。。。“**获取”-因为JSONP始终是get@JaromandaX你说得对。我们按照你说的做了尝试。我们放置了JSON,然后我们得到了如下错误:XMLHttpRequest无法加载。Access-Control-Allow-Headers不允许请求标头字段内容类型。现在您遇到了CORS问题。。服务器需要发送AccessControl Allow标头以允许您获取您已将数据类型设置为jsonp的响应。。。因此,请求将是一个得到-尽管你“想要”一个职位。。。可能服务器端看到GET并发出错误消息,因为它只接受POST方法。。。甚至连服务器端的外观(发出错误的部分)都不知道,只能speculate@JaromandaX谢谢你的回复。塞弗说代码是由某个人写的。他们说我们发帖子。所以我们试着发帖子。请检查我的更新问题和给我们的指南,但你没有发帖子。。。查看错误。。。“**获取”-因为JSONP始终是get@JaromandaX你说得对。我们按照你说的做了尝试。我们放置了JSON,然后我们得到了如下错误:XMLHttpRequest无法加载。Access-Control-Allow-Headers不允许请求标头字段内容类型。现在您遇到了CORS问题。。服务器需要发送AccessControl Allow标头以允许您获取响应
OPTIONS http://192.168.3.226:2468/MyService.svc/UploadSettlementLine 405 (Method Not Allowed) jquery.min.js:4
XMLHttpRequest cannot load http://192.168.3.226:2468/MyService.svc/UploadSettlementLine. Request header field Content-Type is not allowed by Access-Control-Allow-Headers.