I have two questions about the use of an AJAX function.
I am using the following function I found on a forum, mostly WITHOUT problems:
[code=php]
// ReadFile.js
function getFile(filename) {
oxmlhttp = null;
try {
oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType(“text/xml”);
}
catch(e) {
try { oxmlhttp = new ActiveXObject(“Msxml2.XMLHTTP”); }
catch(e) { return null; }
}
if(!oxmlhttp) return null;
try {
oxmlhttp.open(“GET”,filename,false);
oxmlhttp.send(null);
}
catch(e) { return null; }
return oxmlhttp.responseText;
}
The error looks like this, but will change depending upon the first line in the text file that I’m trying to read.
[quote]
Error: syntax error
Source File: [url]http://www.nova.edu/optometry/411/NewSced/DBI/Summer07.txt
Line: 1, Column: 1
Source Code:
post time|user|{|^
It seems to work fine but occasionally (not always) I get an error in the JS error console using FireFox. It gives an error about the TEXT file that I am loading using the routine.
It reports the error, but it does not stop the function from completing nor does it appear to effect the results of the read operation.
So here are my questions:
1. Is there a reason why I’m getting the errors reported but the function appears to work fine and is there a change to the routine I should make to eliminate the error report in the JS console?
2. Will I cause any problem if I repeat the call at a later time in the same script?