Permission denied to call method XMLHttpRequest.open
Have you ever seen something like that? I recently had a very interesting experience within AJAX scripting. Let’s say you will access http://www.domain.ext, right? Now here comes my problem. There is a great difference between
The result? Opera’s console said just: Error, Internet Explorer said nothing, and only the Mozilla browsers did give me a hint. And the hint… an interesting exception of which I didn’t know anything till that moment.
If, let’s say, you’re accessing http://www.domain.ext and the Ajax script is written for http://domain.ext you will receive a very non explicit exception/error found in the title. After long searches on the internet I could not find anything clear, until…
I remembered that once I received this error within another website I was working at. At that moment I did not realize that I did find a solution, but hey… Who’s perfect?
Here’s a real thing. You know already that Ajax does not load on domain.ext pages from domain2.ext. This is a permission rule that cannot be forced that easy, but can can be avoided though a caching script. But did you know, also that Ajax cannot load a page even from a sub-domain of the domain you’re working with? It’s the same bugging rule that’s restricting this and from what I’ve tested till now, it’s true. And what do you think www.domain.ext is considered for domain.ext? Yes… it’s just an ordinary sub-domain…
This is the solution I found for the problem showed above.
Now… If, for example you’re viewing domain.ext and you want do Ajax load something from sdmn.domain.ext, this is a completely different thing, and again it can be done with the caching script I was talking above. We write a simple php file in domain.ext, which will load the html from sdmn.domain.ext. (I will show how in another article, a little bit later. But you can find it on the internet if u ggl a bit.)