Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Cross domain scripting, jQuery and IE8

Cross domain scripting, jQuery and IE8

Scheduled Pinned Locked Moved Web Development
helpjavascriptphphtmlapache
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wjousts
    wrote on last edited by
    #1

    I can't get this damn thing to work and it's driving me nuts. Here's the scenario: Linux box running Apache - set up to send the Access-Control-Allow-Origin * header for the folder I'm working with PHP web service that will build and return a JSON object on a request to mypage.php?project=1 or similar Simple html test page running locally (from the file system) on my machine using jQuery to retrieve the JSON object from my web service like so:

            $.getJSON(url, function (data) {
                $.each(data.factors, function (i, field) {
                    $("div").append(field.FactorName + " ");
                });
            });
    

    Works fine in FF, works fine (on FF and IE) if I upload the page to the same server as the web service and run it form there, doesn't work at all in IE when running the page locally (doesn't look like the response is ever received). I did a little research and it looks like for cross domain scripting in IE you should use XDomainRequest instead of XMLHttpRequest (which I think jQuery is using under the covers in getJSON). So I try this (based on some website):

            if ($.browser.msie && window.XDomainRequest) {
                var xdr = new XDomainRequest();
                xdr.open("GET",url);
                xdr.onload = function() {
                    alert("XDR Sent");
                };
                xdr.send();
            }
            else {
            $.getJSON(url, function (data) {
                $.each(data.factors, function (i, field) {
                    $("div").append(field.FactorName + " ");
                });
            });
            }
    

    On IE it chokes on xdr.open with an "Access is denied" error. Any idea what the problem might be?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups