Skip to content

Domain name – Ajax, Iframe and JSONP

December 11, 2009

“The same origin policy prevents a document or script loaded from one origin from getting or setting properties of a document from another origin. This policy dates all the way back to Netscape Navigator 2.0. Two pages to have the same origin if the protocol, port (if one is specified), and host are the same for both pages.”

More details on this here: https://developer.mozilla.org/en/Same_origin_policy_for_JavaScript

Thus setting document.domain property value allows iframe to communicate with javascript of parent window. However tried doing ajax calls between sub domains with that approach, and it does not work on FF , IE.  JSONP is another approach to execute js on any other site and insert the output  – which should be a function call wrapping JSON in the page itself.  For POST requests however, this approach is not feasible.  Details of this approach are described here: http://www.clientcide.com/wiki/cnet-libraries/06-request/00-jsonp

doing a Cross domain call :

http://stackoverflow.com/questions/1660564/ajax-calls-from-one-subdomain-to-other

http://stackoverflow.com/questions/648899/a-question-about-cross-domain-subdomain-ajax-request

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: