1

We are try to post user_info to server.We are developing hybrid app.Use ajax call we post data to server.But we got error always Error

GET http://192.168.3.226:2468/MyService.svc/UploadSettlementLine?callback=jQuery111107869312851689756_1455787050793&undefined=&_=1455787050794 405 (Method Not Allowed) 

We are tried like this

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);
                      }
                    });

Please guide to us.Tell what wrong in my code.

if we places dataType:json we got error this

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.
  • you've set dataType to jsonp ... therefore the request will be a GET - despite you "wanting" a POST ... perhaps the server side is seeing the GET and issuing the error message as it only accepts a POST method ... without even a a clue of what your server side looks like (the part that's issuing the error) can only speculate – Jaromanda X Feb 18 '16 at 09:42
  • @JaromandaX thanks for reply.Sever said code write by some one.they said we places POST.So we tried with POST Please check my update question and Guide to us – Pavan Alapati Feb 18 '16 at 09:52
  • but you are not sending a POST ... see the error ... "**GET .." - because JSONP is always a get – Jaromanda X Feb 18 '16 at 09:55
  • @JaromandaX Your right.We tried as you said.We places JSON then We got error like this 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. – Pavan Alapati Feb 18 '16 at 09:58
  • now you have a CORS issue .. the server needs to send AccessControl-Allow-Header to allow you to get the response – Jaromanda X Feb 18 '16 at 10:01
  • Check the headers that are set in this answer for CORS: http://stackoverflow.com/questions/298745/how-do-i-send-a-cross-domain-post-request-via-javascript/7605119#7605119 – DenizEng Feb 18 '16 at 10:03

0 Answers0