3

I am trying to get around the lack of support for XDomainRequest in IE6. I think I have a solution but was wondering what the opinion is on this approach?...

I only need to perform GET requests, so instead of trying to create an XDR object, I dynamically append a new script tag to the page when I need to (onclick). The src of the tag would contain all the necessary parameters in the query string. Then I can return the content from the server.

The clever/ugly bit would be to wrap the content in a javascript function that would otherwise have been the onload function of the XDR instance. So what I would effectively be returning is some script containing a function with the xdr.responseText value already inside it.

Thoughts?

Nick
  • 6,366
  • 5
  • 43
  • 62
  • 2
    This technique is called JSONP (…with padding) - of course you can also return strings instead of object literals. You can read a lot on that on the web. Please ask a specific question then. – Bergi Sep 10 '12 at 18:07
  • Should have know it would have a name! Seems like a fairly safe approach for our usage. Thanks. – Nick Sep 11 '12 at 09:53

0 Answers0