I am working on a simple XMLHttpRequest setup that fetches data from an xml file and displays it in a div on my webpage within a ul element:
var requestData;
if (window.XMLHttpRequest){
requestData = new XMLHttpRequest();
}else{
requestData = new ActiveXObject("Microsoft.XMLHTTP");
}
requestData.open("GET", "data.xml");
requestData.onreadystatechange = function(){
if((requestData.readyState ===4) && (requestData.status ===200)){
var itemList = requestData.responseXML.getElementsByTagName('title');
var outputData = "<ul>";
for (var i=0; i<itemList.length; i++){
outputData += "<li>" + itemList[i].firstChild.nodeValue + "</li>";
}
outputData += "</ul>"
document.getElementById('update').innerHTML = outputData;
}
}
requestData.send();
The data is being displayed correctly on the page, but when I check the source code, the new list structure is not visible in the html. Additionally, when I try to style the newly fetched list using CSS like below:
$('document').ready(function(){
var cssStyle = {
"background-color": "#333",
"color": "#FFF",
}
$("ul:last li").css(cssStyle);
});
It doesn't seem to have any effect. After importing the data into my html, how can I target it with CSS and apply styling?