PDA

View Full Version : firefox can't create an XMLHttpRequest


rptodd1
10-30-2006, 11:42 PM
Why are Firefox 1.5 and 2.0 no seeing this method when IE6 does"

here's the import statements followed by the function imported, followed by the script trying to create a XMLHttpRequest, followed by the in document script using the imported createRequest() function.

<script language="JavaScript" src="C:/mydocs/work/docs/AJAX.js"> </script>

that function has a createRequest() that appears below

function createRequest()
{
var request = null;

try
{

request = new XMLHttpRequest();

}
catch (trymicrosoft)
{
// microsoft active x code that's working fine
}
if (request == null)
alert("There was an error creating the request. Please contact Your Daddy.");
else
return request;
}

This call throws a "CreateRequest not defined" error in the JavaScript debugger

<script language="JavaScript">

var request = createRequest();

alert("the request is outside function "+ request);
</script>

Why isn't Firefox seeing the function?

Thanks,

Robert

A1ien51
10-31-2006, 04:02 AM
If it says it is no defined, than your external JavaScript file is probably not loaded.

Eric

rptodd1
10-31-2006, 04:37 PM
Why isn't firefox loading that external file but IE is?

Robert

Kor
10-31-2006, 05:54 PM
Do you expect AJAX to run locally/external with that locally SRC?

src="C:/mydocs/work/docs/AJAX.js

Either you start a "server emulater", such as Apache, to make your PC acting as a server when testing requesting, or you send by FTP that JS file to the server and test it there.

ActiveX object of MS is not the same as the DOM request object, It is not implemented in the same manner in the browser/OS

CFMaBiSmAd
10-31-2006, 06:02 PM
The src="..." contents is fetched by the browser.

This must contain either a relative URL - "somepath/AJAX.js" or it must contain an absolute URL - "http://somedomain/somepath/AJAX.js".

The information you supplied "C:/mydocs/work/docs/AJAX.js" is the location of the file in your computers file system and does not have any meaning to a browser fetching this. If it worked locally for one browser, you got lucky, but this is not the correct syntax.

rptodd1
10-31-2006, 07:43 PM
so how do I reference this in a static file I'mm opening from my hard drive with my browser?

felgall
10-31-2006, 08:06 PM
Specify the path relative to the page that is calling it.