我们尝试将user_info发布到server.We正在开发混合app.Use ajax调用我们将数据发布到server.But我们总是得到错误 错误
GET http://192.168.3.226:2468/MyService.svc/UploadSettlementLine?callback=jQuery111107869312851689756_1455787050793&undefined=&_=1455787050794 405 (Method Not Allowed)
我们这样尝试
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.