views:

440

answers:

3

I'm putting together a little tool that some business people can run on their local filesystems, since we don't want to setup a host for it.

Basically, its just HTML + Javascript (using jQuery) to pull some reports using REST from a 3rd party.

The problem is, FF3 and IE don't allow the ajax call, I get:

Access to restricted URI denied" code: "1012

Obviously its an XSS issue...how do I work around it? The data returned is in XML format.

I was trying to do it this way:

$.get(productUrl, function (data)
     {
      alert (data);
     }
    );

EDIT: To be clear...I'm not setting up an internal host for this(Way to much red tape), and we CANNOT host this externally due to the data being retrieved.

EDIT #2: A little testing shows that I can use an IFRAME to make the request. Does anyone know if there any downsides to using a hidden IFRAME?

A: 

If you have Python installed, a webserver to serve files can be as simple as

python -c “import SimpleHTTPServer;SimpleHTTPServer.test()”

Edit: Original poster can't use this approach, but in general I think this is the way to solve this particular problem for future users with this issue.

Greg
We have a no server policy on workstations...and this is to protect users from themselves.
FlySwat
+2  A: 

In a similar situation, my solution was to use Mark Of The Web, which is a special HTML comment that IE recognizes. It places the page in a different security zone.

Reference: MSDN

Chris Lundie
"..enabling Internet Explorer to force Web pages to run in the security zone of the location the page was saved from—as long as that security zone is more restrictive than the Local Machine zone" So doesn't that not work then?
Greg
Good point. I get a bit confused over which zone is more or less "restrictive", since adding the MOTW will allow your code to run, wouldn't that make it less restrictive? Depends on how you look at it.
Chris Lundie
By "more restrictive" they mean it can't load from the local filesystem as such.
Frank Schwieterman
A: 

Do you control the server providing the data? If so you can setup a callback. The basic idea is you have a function in the script that handles incoming data (in your case an XML string). Then the server responds to the request with a Javascript snippet of your callback funtion with the string as the argument. And instead of using AJAX, you add a new script tag to the page. This is the basis for JSONP. It looks something like this.

local page.

<script>
 function callback(str)
 {
  alert(str);
 }
 function makeRequest(param)
 {
  var s = document.createElement('script');
  s.src = 'http://serveranywhere/script.bla?' + params;
  document.getElementsByTagName[0].appendChild(s);
 }
</script>

remote server returns

callback('<xml><that><does><something></something></does></that></xml>');

now when the script is added to the page, the function callback will be executed you the string you provide. And jQuery call do all of this for you using JSONP in the $.ajax call. Hope this helps.

Morgan ARR Allen