Mechanic
From: The ever so loving Macedonia:)
Registered: 2006-09-18
Posts: 64
I've been thanked 3 times.
Offline
Hello people,
Hope you don't mind me bothering you with a question or two:
I have the following code on a page so I can later fill in the div with code from another file:
Code:
<div id="pagepreview">
</div>
I also have an inclusion link to the javascript file in the header, and the following code added as a separate JavaScript code:
Code:
function makeUpdates()
{
getAXAH('pages/'+(postForm.StyleOption.selectedIndex+1)+'/'+postForm.SizeOption.options[postForm.SizeOption.selectedIndex].value+'.html','pagepreview');
return true;
}
The JS file itself, contains the following code:
Code:
var xmlhttp,alerted
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
try {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
} catch (E) {
alert("You must have Microsofts XML parsers available")
}
}
@else
alert("You must have JScript version 5 or above.")
xmlhttp=false
alerted=true
@end @*/
if (!xmlhttp && !alerted) {
// Non ECMAScript Ed. 3 will error here (IE<5 ok), nothing I can
// realistically do about it, blame the w3c or ECMA for not
// having a working versioning capability in <SCRIPT> or
// ECMAScript.
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
alert("You need a browser which supports an XMLHttpRequest Object.\nMozilla build 0.9.5 has this Object and IE5 and above.")
}
}
function getAXAH(url,elementContainer) {
if (xmlhttp) {
d=document
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.getElementById(elementContainer).innerHTML=xmlhttp.responseText
}
}
xmlhttp.send(null)
}
}
This works in IE with no problem, but refuses to work in Firefox (usually its the other way around for me, so it's a bit weird). I have tried a few other methods (including some I've been using successfully in the past as well) but neither wants to work.
The function of the code is to retrieve an URL with a set page, and include the contents of that page into the "pagepreview" div.
Any help as to why Firefox won't like the code is appreciated.
Moderator
From: Yorkshire, UK
Registered: 2006-08-19
Posts: 2818
I've been thanked 81 times.
Offline
Firstly, Get firebug [FF plugin] - this will show you any errors
Secondly, I use a javascript framework (jquery) and the ajax api in that never fails for me
Thirdly, check that the file you're trying to request is on the same domain (including sub-domain) as the file making the request - this is a security fix by the browser to prevent malicious cross-site scripting and could have been implemented after your version of IE and before your version of FF
Mechanic
From: The ever so loving Macedonia:)
Registered: 2006-09-18
Posts: 64
I've been thanked 3 times.
Offline
Northie! Firebug rocks 
| Never |


