Note that there are some explanatory texts on larger screens.

plurals
  1. POIE cross domain ajax invocation XDomainRequest error
    text
    copied!<p>I have to use the following code to logout from a page in an Iframe</p> <pre><code>//The javascript code is in a page in my-domain //it tries to logout from the page in other-domain $(window).unload(function() { if ($.browser.msie &amp;&amp; window.XDomainRequest) // IE { var xdr = new XDomainRequest(); if (xdr) { xdr.onerror = function(){alert("XDR onerror");}; xdr.ontimeout = function(){alert("XDR timeout");}; xdr.onprogress = function(){alert("XDR onprogress");}; xdr.onload = function(){alert("XDR onload");}; xdr.timeout = 5000; xdr.open("GET", 'http://other-domain/.../j_spring_security_logout'); alert("before send"); xdr.send(); alert("after send"); } else alert('Failed to create new XDR object.'); } else // firefox $.getJSON( 'http://other-domain/.../j_spring_security_logout?callback=?', null); }); </code></pre> <p>However, I get alter boxes in IE8 in the this order: "before send", "XDR onerror", "after send".</p> <p>I have the following code in server side</p> <pre><code>@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) res; response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS"); response.setHeader("Access-Control-Max-Age", "360"); response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); chain.doFilter(req, res); } </code></pre> <p>I can verify that the logout works perfect for Firefox after I use $.getJSON and response.setHeader("Access-Control-Allow-Origin", "*") and so on; however it doesn't logout when I use IE.</p> <p>Then I found this comment online:</p> <pre><code>"For cross-domain, IE requires you to use XDomainRequest instead of XMLHttpRequest. jQuery doesn't do it so you have to do it manually:" </code></pre> <p>So I added XDomainRequest. However, I got my alert dialog "XDR onerror" in IE8. What should I add to make this cross domain call in IE?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload