...

View Full Version : Ajax Simple Request :/



martynball
07-21-2010, 02: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();
}

Rowsdower!
07-21-2010, 06:36 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();
}


I believe these should be "XMLHttpRequest" rather than "XMLHttpxmlhttp" to make this work.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum