If you need to do a POST without needing to read the result, you can just set the action of a <form> to the correct URL (forms can post cross-domain). If you want to read the result, here’s one slightly hacky approach:
1. Create an iframe with a name. 2. Set the target of your <frame> to the iframe. 3. Post the form 4. Have the page that processes the POST redirect back to a page on the original domain that contains the necessary data. 5. Have the page on the original domain call out of the iframe to let the containing page know it’s data is ready. As I said, slightly hacky. If your browser support level was higher (IE8+, Firefox 3+), you could accomplish this much more easily using cross-document messaging. Of course, the “old way” of doing cross-domain Ajax is to setup a proxy on the first domain’s server that contacts the second domain for you. That way, you just use regular Ajax and the heavy lifting is done on the server. You will have to secure that proxy with some sort of token/whitelist combination or other authentication, to ensure that you don’t open a security hole, but it’s still a decent approach if you have access to the server. -Nicholas _____________________________________________________ Nicholas C. Zakas Twitter: @slicknet Blog: http://www.nczonline.net/ From: Code Glory Sent: Tuesday, December 14, 2010 6:42 PM To: [email protected] Subject: Re: [JSMentors] Asynchronous cross-domain post from JavaScript Guys, Thanks for the great answers. I will start looking into the various options posted here and get back to you with more questions:) Meanwhile as per some requests, I am adding more detail here- I am mainly looking at HTTP POST. GET is not an issue. We pull various financial widgets into our dashboard and each of these widgets come from different domains. Some are purely read only reports while others let you enter information and perform other actions that require us to do a POST for various other reasons and hence the need for asynchronous cross-domain post from JavaScript. Also, we need this work on major browsers such as IE7+, FF 3.5+, Chrome, Safari 2.0. Hope this helps. Thanks, Srikar On Tue, Dec 14, 2010 at 10:26 AM, Rey Bango <[email protected]> wrote: Hey Sid, I've seen EasyXDM mentioned several times for this. http://easyxdm.net/ Øyvind Sean Kinsey did an article for Script Junkie about cross-domain messaging as well and it used EasyXDM as the basis for it. http://msdn.microsoft.com/en-us/scriptjunkie/ff800814.aspx Rey... On Mon, Dec 13, 2010 at 11: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 mailto: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 mailto: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] -- 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]
