Hi all,
Longtime lurker, first time poster. ?
I have a conundrum. I’m using a very simple AJAX script to open an external data file (a plain HTML page, really) and I’ve run into quite the head scratcher. I’ll post the relevent code below, but basically, everything works in IE/FF/Safari on our local development box, but when we push it out live to the internet and people access it from offsite servers, it fails in FF/Safari while continuing to work in IE. But it doesn’t fail for us in production, perhaps because our production/live servers are on the same physical network as we are. So it seems to be failing on the XMLHttpRequest.open() function, but again, only in FF/Safari. Any ideas?
(This code is included in the base HTML page and called via a form)
[CODE]function init(url, target) {
document.getElementById(target).innerHTML = ‘ Retrieving Data…’;
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject(“Microsoft.XMLHTTP”);
}
if (req != undefined) {
req.onreadystatechange = function() {initDone(url, target);};
req.open(“GET”, url, false);
req.send(“”);
}
}
function initDone(url, target) {
if (req.readyState == 4) { // only if req is “loaded”
if (req.status == 200) { // only if “OK”
document.getElementById(target).innerHTML = req.responseText;
} else {
document.getElementById(target).innerHTML=” Error:n”+ req.status + “n” +req.statusText;
}
}
}
function load(name, div, from, to) {
if (from == “” || to == “”) {
document.getElementById(div).innerHTML = “ Please select both From and To…”;
} else {
init(name,div);
return false;
}
}
And I’m calling it with an <Input> as below:
[CODE]<input type=”image” name=”searchBtn” src=”/images/go.gif” id=”searchBtn” value=”GO” style=” ” o
nclick=”load(‘/includes/menu.html’,’my_menu’, document.drop_list.Category.value, document.drop_list.SubCat.value);return fal
se;”/>
Thanks a bunch for looking. Feel free to ask any follow-up questions.