Hi guys,
I want to use the Bing's search api with javascript. Actually, I want the user to write something and query Bing in order to get just images.
so, I tried it using ajax. If I try the url http://api.search.live.net/xml.aspx?Appid=[YOURAPIKEY]&sources=image&query=home directly (with the browser) I do get an xml document.
but if I use XMLHttpRequest it does not work.
<html>
<body>
<script>
var xhr = new XMLHttpRequest();
var url="http://api.search.live.net/xml.aspx?Appid=[YOURAPIKEY]&sources=image&query=home"
xhr.open("GET", url, true );
xhr.onreadystatechange=function(){
/*if( xhr.readyState == 4 && xhr.status == 200) {
document.write( xhr.responseText );
}*/
alert( "state: "+xhr.readyState +" status: "+xhr.status +" statusText: "+xhr.statusText +" respText: "+xhr.responseText);
};
xhr.send(null);
</script>
</body>
</html>
Questions: 1) why does the code from above does not work? 2) any other way to do this without XMLHttpRequest?
thanks.
btw. I'm just interested in fix this for Firefox and without external libraries (jquery and so on).