Click here to Skip to main content
15,885,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,
I am trying to do a call to webservice method and it returns a string. when I try to access this methos using $.getJSON I am able to hit the method but even i am gettign resposnse from web service but I am unable to enter into below function . I am just watching in console that I am getting response... If I use ajax call i am geting cross domain issue... Please help me out .....

HTML
   $.getJSON('https://172.16.25.47/JsonPTestApp/clurcService.asmx/getRCjson?SPA=8353/1000/0140',  function (data) 
{
              alert("came inseide")
              var test = data;
              alert(test);
 });
Posted
Comments
Sinisa Hajnal 29-Jan-15 2:53am    
Google this: "ajax call cross domain safety"
jing567 29-Jan-15 2:54am    
From past two days I am googling.... If you know the working solution please let me know
I am loading the service in browser. But it does not load.
jing567 29-Jan-15 23:20pm    
Sry Tadith as per security issues... I have given wrong I.p address... i just tried to show the mock code....

1 solution

CORS (Cross Origin Resource Sharing) issues are caused when the origin does not match the destination address / host name and the server has not specified that this behavior is allowed. The simple solution to this is to make the server (this case a asmx service) return the header that allows your origin. If you have a domain you are running this from you can specify this domain, otherwise you need only specify the * wildcard to allow all origins.

I haven't written asmx before however i think a solution could look like :

HTML
Response.AddHeader("Access-Control-Allow-Origin","*")


Hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900