View Full Version : SECURITY_ERR: DOM Exception 18

Kenneth Heeres
07-17-2012, 10:55 PM
I have a web page in which the Javascript code does a XMLHttpRequest and it gets the titled error above. This happens with a mobile browser but not on the browser on my iMac. I am accessing the web page using https://sitea.domain and the XMLHttpRequest goes to https://siteb.domain. The error occurs when the open is executed.

Any ideas?

Old Pedant
07-18-2012, 12:50 AM
Different security models in the two browsers.

The one that allows it sees sitea.domain.com as indeed coming from the same domain as siteb.domain.com.

The one that disallows it is treating them as separate domains.

And easy answer would be to put a proxy server (maybe written in PHP or ASP or...) on sitea.domain that acts to pull the data from siteb.domain. So that the XMLHTTPRequest would then hit the proxy on sitea.domain.

As to why the different security models: No idea. As the browser makers.

07-18-2012, 02:19 AM
Hi Kenneth Heeres,
You can't use XMLHttpRequest to access data in different domain but you can import javascript insert, most popular method is JSONP (but not me, I just sent entire code back since I know what I sent back).

rnd me
07-18-2012, 07:24 AM
if you control both domains then simply add the proper CORS headers to the page(s) you want to fetch with ajax:

Access-Control-Allow-Methods: GET
Access-Control-Allow-Origin: *

see https://developer.mozilla.org/en/http_access_control for info