title: Calling cross domain asmx web service using JavaScript
body: <p>I have written a web service. I am calling this web service using JavaScript. I am calling this from different domain. For that I have added <code>[System.Web.Script.Services.ScriptService]</code> property in the web service. From JavaScript I am calling the service using <strong>XMLHttpRequest</strong>. I tested it using Firefox and everything was fine when. But it was not working in IE. </p>
  
  <p>After some searching I found that this is an issue related to <strong>Cross domain calling</strong>. I have gone through some of the questions posted here. And then I did the following changes in my code - </p>
  
  <ol>
  <li><p>From javaScript I am now calling the service using <strong>XDomainRequest</strong>. </p></li>
  <li><p>I have added following lines befor the return statements in the web-service - <code>HttpContext.Current.Response.AppendHeader("Access-Control-Allow-Origin", "*");
  HttpContext.Current.Response.AppendHeader("Access-Control-Allow-Credentials", "true"); 
  return result;</code></p></li>
  </ol>
  
  <p>It is still working fine in firefox. but in IE8 (as per my knowledge, XDomainRequest will not work in lower versions of IE) it is showing error (<strong>XDomainRequest.onerror</strong>).</p>
  
  <p>Am I missing something?</p>