Depends on what type of request you are wanting to make. HTTP GET? JSONP is your best bet. It's simple, and well supported by browsers and libraries alike (it's just dynamically creating a <script> tag). HTTP POST? Then you have to rely on some hackery. While I haven't used Dojo's cross-domain XHR hack, that's the one I see people point to most often.
If I ran into the need for an XHR POST, I'd look at YQL. That works by you sending an XHR GET to the YQL servers, then it will in turn fire a POST for you, and return the results in JSONP. Very handy. NCZ has a good post regarding CORS, but you are limited with legacy support in older browsers. http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/ If you could be a bit more descriptive of your use case, I bet we can come up with the best solution. On Mon, Dec 13, 2010 at 8:09 PM, Glory <[email protected]> wrote: > Hi, > > I am new to this group and was using Stack Overflow (SO) to follow the > latest and greatest in the field of JavaScript. I have a question to > all the JS gurus here. How are you handling the asynchronous cross- > domain post from Javascript currently? Most of the answers on SO > suggest using iFrame. Is that the only way? What are the best > practices around this? I think YUI has some capabilities but what > about jQuery? > > Thanks, > Sid > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected]<jsmentors%[email protected]> > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
