Re: Using XMLHttpRequest in Firefox

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance





Trevor L. wrote:


But, won't it only open XML which is at the same site,

Yes, as said client-side script in browsers is restricted by same origin policy, that holds for Mozilla and Opera as well as for IE, you will get a permission denied exception with Mozilla on the open call, check Mozilla's JavaScript console. Opera 8 gives a security violation exception in its JavaScript console. IE gives a permission denied error dialog (if configured to display script errors/exceptions).


so I have to mess with it?

Then go ahead and mess with the code by doing unrelated things like document.onreadystatechange checks. But your script won't gain any permissions that way.


At the risk of being repetetive, the code below works in IE6, but not in Firefox.

IE has different zones which can be configured in terms of security so it might be that you load the document with the script in a zone like the trusted site zone or the local zone where settings are changed to allow access to other origins. But with normal settings for the internet zone IE will give you permission denied as well if you try to load XML from e.g. http://abc.net.au/ while your document with the script is from another internet origin.



--

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
.