I was trying to read an XML data provided by the url
but I not able to get a responce back using the following code:
var xhr;
if (window.XMLHttpRequest) xhr = new XMLHttpRequest(); // all browsers except IE
else xhr = new ActiveXObject("Microsoft.XMLHTTP"); // for IE
xhr.open('GET', 'http://api.123rf.com/rest/?method=123rf.images.search&apikey=0c29eba8ae174db26c5946b2f4e7b3c4&keyword=dance&orderby=most_downloaded&perpage=20&media_type=all', false);
xhr.onreadystatechange = function () {
if (xhr.readyState===4 && xhr.status===200) {
var items = xhr.responseXML.getElementsByTagName('image');
var output = '<ul>';
for (var i=0; i<items.length; i++) output += '<li>' + items[i].id + '</li>';
output += '</ul>';
var div = document.getElementById('update');
div.innerHTML = output;
}
}
xhr.send();
I am able to view the data if I download the xml file and upload it directly to my host. Is there a way to view the data from an external url and displaying it using Javascript?
Thanks.