making ajax request to another server

Posted by santhosh on Stack Overflow See other posts from Stack Overflow or by santhosh
Published on 2010-05-17T17:14:24Z Indexed on 2010/05/17 17:20 UTC
Read the original article Hit count: 192

Filed under:
|

Hi, I had a ajax sample code from W3Schools, where If i request ajax call to remote server the request getting fails.

function loadXMLDoc()
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","http://www.google.com",true);
xmlhttp.send();
}

How to solve this..?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about AJAX