So here is the javascript file of the code I am writing, this is basically a copy paste of a program that seems to work on everybody's computers except mine, essentially I never see alert'2', the xml file is in the same directory as the html and js file
var pop=0, countries = 0, continents = 0, cities = 0;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
alert('1');
//alert pops up
xmlhttp.open("GET","mondial.xml",false);
xmlhttp.send(); //error
alert('2');
//this alert does not
xmlDoc=xmlhttp.responseXML;
document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("country");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
var temp = parseInt((x[i].getElementsByTagName("population")[0].childNodes[0].nodeValue));
pop+= temp
document.write(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
alert(pop);
No comments:
Post a Comment