views:

79

answers:

2

Hi there,

I have a page where a user can upload a file along with some other input. Because I wanted this to be AJAX-like, I resorted to using an iFrame to accomplish this.

After the file is uploaded and an iFrame is loaded with a response page, I need to update a DIV outside of the iFrame with an AJAX call. The reason for separate updates, is that the result of the outside DIV depends on the input that the user provided with the file input.

Can this be done? Am I approaching this the wrong way?

Thank you!

UPD: Can the returned client code from within the iFrame "see" elements outside that iFrame?

A: 

Yes , it can be done. But you can do away with,the need for an AJAX-call , to update the outside the div.

Have your, servlet(assuming you are using JSP/servlets) that accepts the mutlipart request(the servlet that accepts the upload), return the intended response (to be shown on the refreshed iFrame), and ALONG WITH IT, the necessary information from the file input. This way you have all the necessary details on the client, in one response. A simple javascript function can achieve , updating the outer div with the information from the file input.

The Machine
I like that! I'm using PHP, but all the same.I guess the question is, will the response client code from within the iFrame see the outside DIV? This is where I seem to have a problem.
KcYxA
I got this with David's help above! I don't know how I didn't think of what you were suggesting regarding multiple AJAX calls. Thank you!
KcYxA
A: 

Write your code in the onload event of the page loaded into the iframe. Then top will give you the top frame or parent will give you the parent frame.

David Dorward
It worked! The code from the onload event in the iFrame could grab the outside DIV - thank you!
KcYxA