As you will notice with my code below I'm returning data using responseText. I want to return it as XML data:
//Request is a flickr URL with user entered search terms:
function sendRequest (request) {
x = new XMLHttpRequest();
x.open("GET", request,true);
x.onreadystatechange = function () {
if (x.readyState==4 && x.status==200){
//The data is returned as text and added to the page:
document.getElementById("resultsContainer").innerHTML="success: Raw JSON data below <br> <br>"+x.responseText;
document.getElementById("getIms").value = "Find Images";
document.getElementById("getIms").style.background="white";
} else if (x.status == 404){
document.getElementById("resultsContainer").innerHTML="Not Found";
}
}
x.send();
}
The value that is returned and displayed on the page is something like:
jsonFlickrApi({"photos":{"page":1,"pages":476982,"perpage":1,"total":"476982","photo":[{"id":"14021160561","owner":"91285504@N05","secret":"dd4f545e17","server":"2920","farm":3,"title":"barack-obama-painting","ispublic":1,"isfriend":0,"isfamily":0}]},"stat":"ok"})
I need to be able to use this to extract the photo info to construct an image URL to be displayed on screen. But to my understanding I would need to return the value using responseXML rather than responseText.
I have tried responseXML but it gives me back null.