troubleshooting Question

Workarounds for Cross Domain (localhost + other) AJAX calls?

Avatar of TimYates
TimYatesFlag for United Kingdom of Great Britain and Northern Ireland asked on
7 Comments2 Solutions2251 ViewsLast Modified:
I have a website where I am using DWR to call the server in an AJAX style, however I now have a requirement to show user related data alongside that stored on the server.

My initial thought was that I could run a Java application (embedding Jetty) on the user's machine, and then load JSON from it by using an XHR request using the localhost:8888 url.

However, I'm getting security exceptions on the method...

I thought you were allowed to load stuff from localhost?  I guess not, when the main page url isn't from there...

Does anyone have any ideas on how this can be done?  I don't want to upload the user's data (as it's huge), and so far I have the following ideas -- just wondering if anyone had any experience and knew of a way of getting this to work?

1)  Have the server running on localhost serve an html page which can be loaded into a hidden IFRAME on the main page.  Then have this IFRAME load the data into a JSON object from localhost, and then pass this JSON object back to the parent window (sounds convoluted, and would be nice to know if it might work before I try it)
2)  Do it the way I am doing it, but do it right ;-)  (I accept that the way I'm doing it MIGHT work, and it's just I have given up too easily)
3)  Forget about it...  It can't be done... (I know this is always a possible solution to problems like this)

Anyway...hope someone who has walked this path before can help :-)


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros