0

I am new to Javascript/jQuery. Can we call web service through jQuery Ajax for cross domain. If yes how?

When I am trying to call it is giving access denied error.

Please help me to resolve this issue

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
  • 4
    Whats your scenario. What have you tested? First google hit: [cross domain ajax](http://stackoverflow.com/questions/3506208/jquery-ajax-cross-domain) – Martin May 05 '15 at 07:57
  • If you provide the code you have tried. One way around this is to use ```JSONP``` – Paul Fitzgerald May 05 '15 at 08:16
  • Additionaly, you can set `crossDomain:true` in options to your `$.ajax` call (preferably using `JSONP`). Please read the [$.ajax documentation](http://api.jquery.com/jquery.ajax/). – Rohit416 May 05 '15 at 09:03
  • function CallWebService() {var val1 = document.getElementById("txtNo").value; $.ajax({ type: "post",crossDomain: true,url: "http://SiteName/Student.asmx/GetStudentDetails", data: "{'studNumber'='" + val1 + "'}", contentType: "application/json; charset=utf-8", dataType: "JSONP",Success: function (result) {alert(val1); OnSuccess(result); },error: function (xhr, status, error) {OnFailure(error);} });} function OnSuccess(result) { if (result) {alert(result); } } function OnFailure(error) { alert(error); } – Bobi Garaga May 05 '15 at 10:43

0 Answers0