Calling a web service from IE works, but does not work in Chrome and Mozilla

I am calling a web service using this code:

function CallService() { $.ajax({ type: "GET", url: "http://devpc4:5566/Service1.asmx/GetItems", dataType: "json", data: "{}", contentType: "application/json; charset=utf-8", success: OnSuccess, error: OnError }); } 

OnSuccess Function:

 function OnSuccess(data, status) { alert("success"); alert(data.d); alert("success1"); var ponse = '{"TableNo":"2"}'; alert(ponse.TableNo); } 

OnError:

 function OnError(request, status, error) { alert(status); } 

it gives me output in IE, but I do not get output in chrome and mozolla.
thanks for the help.

+2
source share
2 answers

By adding these three headings you can get your result

  • Access-Control-Allow-Origin

  • Access-Control-Allow Methods

  • Access-Control-Allow-Headers

+2
source

got a solution using this link , my work.
But I have to add a few more headers like:

 Access-Control-Allow-Origin Access-Control-Max-Age Access-Control-Allow-Methods Access-Control-Allow-Headers 

now works in mozilla and chrome. thanks.

+1
source

Source: https://habr.com/ru/post/891137/


All Articles