logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Security Error Problem
Author
SnowCritter



Joined: 11 Feb 2009
Posts: 1
Location: St. Cloud, MN

PostPosted: Thu 05 Mar '09 18:06    Post subject: Security Error Problem Reply with quote

I'm running Apache 2.2.10 on a SuSE Linux 11.1 box. It's DNS name is "labserver" and has an IP address of 192.168.1.243.

I'm experimenting with the Dojo Toolkit and have run into a snag while working with some rudimentary AJAX functionality. Here's the HTML code for the "hello.html" file:
Code:

<html>
<head>
<title>Hello, Ajax World!</title>
<script type="text/javascript"
   src="./dojoroot/dojo/dojo.js">
</script>
<script type="text/javascript">
function hello() {
   dojo.xhrGet( {
      url: "http://labserver/school/ajax.txt",
      handleAs: "text",
      timeout: 5000,
      load: function(response, ioArgs) {
         dojo.byId("cargo").innerHTML = response;
         return response;
      },
      error: function(response, ioArgs) {
         console.error("HTTP status code: ", ioArgs.xhr.status);
         return response;
      }
   });
}
</script>
<script type="text/javascript">
   dojo.addOnLoad(hello);
</script>
</head>
<body>
<div id="cargo" style="font-size: big"></div>
</body>
</html>


When I use a Firefox browser, the code works as it's supposed to when I visit the URL "http://labserver/school/hello.html". However, if I attempt to visit the URL "http://192.168.1.243/school/hello.html" I get the following error messages in the Error Console:
Quote:

Security Error: Content at http://192.168.1.243/school/hello.html may not load data from http://labserver/school/ajax.txt.

and
Quote:

[Exception... "Access to Restricted URI denied" code:"1012" nsresult:"0x805303f4 (NS_ERROR_DOM_BAD_URI)" location:"http://192.168.1.243/school/dojoroot/dojo/dojo.js Line:16"]


If I modify the "url:" value inside the "hello" function to read 'url: "http://192.158.1.243/school/ajax.txt"' then the behavior is reversed. That is to say that the URL "http://192.168.1.243/school/hello.html" works OK and the URL "http://labserver/school/hello.html" does not. The error messages show up in the Error Console with the various particulars reversed.

Now, it occurred to me while I was writing this that if I made sure that the "server" part of the URL matched the server part specified in the "url: value things would work out fine. But since I've come this far I'd like to know if there's anything in the Apache configuration that would allow for either to work. It has also just occurred to me that it could be something in the way JavaScript handles the URI.

In either case, a gentle "look, dummy, it's like this" would be appreciated.

Thanks in advance.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 05 Mar '09 18:21    Post subject: Reply with quote

That is because javascript polices does not allow scripting over different servers and or your sever can't resolve the name to the ip.
So you should use url: "http://192.168.1.243/school/ajax.txt", instead of
[b]url: "http://labserver/school/ajax.txt",
Back to top


Reply to topic   Topic: Security Error Problem View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner