我们尝试使用ajax调用将数据发布到服务器。但它始终会出错
var object1=[{"billtocustomerno":"UBG/00816","no":"325/2016/0291/1242","itemnumber":"FG/1071","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"}];
jQuery.support.cors = true;
$.ajax({
type: 'POST',
url: 'http://192.168.3.234:2468/MyService.svc/UploadSettlementLine',
dataType : 'json',
data: object1,
success: function(data){
debugger;
alert(data);
console.log(data);
},
error: function(XHR, textStatus, errorThrown) {
debugger;
alert(textStatus + ":" + errorThrown);
}
});
我们收到错误
XMLHttpRequest cannot load http://192.168.3.234:2468/MyService.svc/UploadSettlementLine. Origin file:// is not allowed by Access-Control-Allow-Origin.
请指导我们并告诉我在我们的代码中工作的内容 我们尝试更改JSON - JSONP,在这种情况下我们得到了像这样的错误
GET http://192.168.3.234:2468/MyService.svc/UploadSettlementLine?callback=jQuery1110010706594679504633_1455269431090&undefined=&_=1455269431091 405 (Method Not Allowed)