|
Reading XML response from IFrame
 |
Hi Everyone,
I am using the IFrame technique for uploading the photos. I am able to use the IFrame as a target to a form and can see the server's XML response appear in the IFrame.
Is there a way to read the XML response in the IFrame using javascript so that I can hide the IFrame and pop up a nice alert to show the result.
Thanks,
Sanjay.
Posted at 5:15AM, 26 July 2008 PST
(
permalink
)
|
 |
I guess you could parse the contents of the iframe as a DOM tree (either directly or using XSLT) but, wouldn't it be easier for you to request a json reponse instead of the IFRAME technique?
Posted 6 months ago.
(
permalink
)
|
 |
Hi Luis,
Thanks.
I am really just a newbie at this point therefore starting off with a simple solution.
I am trying to find out what how to access the DOM tree of the IFrame so that I can retrieve the xml loaded into the IFrame.
Sanj.
Posted 6 months ago.
(
permalink
)
|
 |
I'm not much versed on Javascript so I can't help you much; sorry.
Perhaps you could google for XML tutorials, etc.; or check in A List Apart, XML.com, etc.
Posted 5 months ago.
(
permalink
)
|
 |
I don't know the exact context of what you are trying to do.
However, It is usually not possible to read an iframe's content from the calling frame when the iframe's domain is different from the calling frame's domain (I guess it is the case because the iframe may be at flickr whereas the calling frame should be on your site).
This is a browser limitation to avoid Cross site scripting attacks.
This limitation is not implemented in thrusted scripting environments like HTML Applications (let me know if you want the javascript object path to get the iframe contents in this context).
What is usually done in this kind of situation is to setup a proxy page on your domain (your site) which you POST your request onto.
Then, server side your proxy page requests the flickr page (it somehow forwards your request to flickr) and forwards the flickr response as its own response. In this case, the iframe and the caller frame are on the same domain which allows the data access.
As you understand, the proxy is the tricky piece of work.
Also, to perform the actual POST and response retrieval, AJAX toolkits (internally using XMLHttpRequest) are commonly used. This doesn't prevent from using the above mentioned proxy.
Posted 5 months ago.
(
permalink
)
|
 |
Thanks! I have resorted to something more crude for now i.e.just display the result in pop-up. I will look into the proposed solutions in due course.
Posted 5 months ago.
(
permalink
)
|
Would you like to comment?
Sign up for a free account, or sign in (if you're already a member).
|
|