martynball
07-21-2010, 01:12 PM
All I need to do at the moment is get the contents of a file from the server and display it in a div. Need to further develop it when this works though.
But for some reason this function is not receiving the txt file which is in the same directory as the script :/
function getHTTPObject() {
var http = false;
if (window.XMLHttpxmlhttp) {
http = new XMLHttpxmlhttp();
} else if (window.ActiveXObject) {
http = new ActiveXObject("Microsoft.XMLHTTP");
}
return http;
}
function testing() {
var xmlhttp = "";
xmlhttp = getHTTPObject();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp == 200) {
document.getElementById('testing_ajax').innerHTML = xmlhttp.responseText;
}
}
};
xmlhttp.open("GET", "txt.txt", true);
xmlhttp.send();
}
But for some reason this function is not receiving the txt file which is in the same directory as the script :/
function getHTTPObject() {
var http = false;
if (window.XMLHttpxmlhttp) {
http = new XMLHttpxmlhttp();
} else if (window.ActiveXObject) {
http = new ActiveXObject("Microsoft.XMLHTTP");
}
return http;
}
function testing() {
var xmlhttp = "";
xmlhttp = getHTTPObject();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp == 200) {
document.getElementById('testing_ajax').innerHTML = xmlhttp.responseText;
}
}
};
xmlhttp.open("GET", "txt.txt", true);
xmlhttp.send();
}