2

I want to call ASMX service from my another domain. So far I have the following code of sample:

e.preventDefault();
var CityName = {};
CityName.Name = $("input#name").val();
$.ajax({
    data: '{name:' + JSON.stringify($("input#name").val()) + '}',
    url: 'http://192.168.1.110/forgetit//webservice.asmx/CityTestExample',
    contentType: 'application/json; charset=utf-8',
    method: 'post',
    dataType: 'json',
    success:
        function(data, textStatus, XMLHttpRequest) {
            alert("data Saved");
        } 
    });
});

basically from one domain i wants to insert data that is call asmx service from another domain how should i get this my web console give me this error

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header please give me any suggestion it will be very helpful for me thanks.

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
raja atif
  • 45
  • 6

1 Answers1

0

The domain hosting Web service should enable the cross domain policy. There are many ways to enable this. Please see the MSDN link for more details.

https://msdn.microsoft.com/en-us/library/dd470115(VS.95).aspx

Avinash Jain
  • 7,200
  • 2
  • 26
  • 40