Reputation: 2889
the problem is that when i want to get the response from the server then it gives null
//url of web service
url="http://www.google.com/ig/calculator?hl=en&q=12INR=?GBP"
var xmlHttp=new xmlHttpRequest();
//object of xml request
xmlHttp.open('GET', url, true);
//get method
xmlHttp.onreadystatechange = function(){
try{
if (xmlHttp.readyState != 4)
return;
alert(xmlHttp.responseXML);
var result = xmlHttp.responseXML.documentElement;
var jsonString = result.childNodes[0].nodeValue;
var result1 = jsonParse(jsonString);
alert(result1.rhs);
document.getElementById('results').innerHTML = innerHTML;
}
catch(e1){alert("erroe="+e1);}
};
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.send(null);
}
Upvotes: 1
Views: 311
Reputation: 69934
You can't do an AJAX call to www.google.com unless your page is already being served from the www.google.com domain.
https://developer.mozilla.org/en/Same_origin_policy_for_JavaScript
Upvotes: 4