Jump to content

How does one pass data from an iframe to its parent dialog window?


Recommended Posts

I'm trying to upload pictures in a modal dialog window.  So I got this idea to submit the form that processes the upload into a hidden iframe within the dialog window.  That works, fine(the pictures get uploaded), but I can't figure out how to send back feedback info from the iframe to the modal window.  I tried to echo some error/success variables into the dialog window from the processing form. Instead what happens is when the upload process is done, a fresh window of the page holding the dialog box opens, the old page with the still open dialog box remains static.  So what seems to be happening is the data is being sent from the iframe to the parent of the dialog, not the dialog itself.  Anyone knows how I can accomplish what I want? All the threads I've seen so far only deal with transferring data from iframe to parent window, none specifically deals with a parent dialog window. Now here is the code I'm dealing with.

 

the dialog window is a div with id "pic_dialog"  It contains the form, the iframe and the feedback div

 

	<div id = "pic_dialog">



	<form  enctype="multipart/form-data" action="picture_upload.php" target = "picture_upload_iframe" method="post">

		 <div> Upload A Picture </div> 

                         <input name="MAX_FILE_SIZE" value="10000000" type="hidden">

                         <input name="picture" accept="image/jpg, image/png, image/jpeg, image/bmp, image/gif, video/*" type="file"> 

		 <button class = "button" name="submit" type="submit"> Submit! </button> 
                         					
                </form>



	<iframe name="pic_upload_iframe" src="" style="visibility:hidden;"></iframe>



	<div id="pic_upload_feedback"> </div>





</div> <!--closes pic dialog>


 

 

Then at the end of the picture_upload.php script which handles the form, after checking if the picture has uploaded successfully, I include this line to send the feedback. The session variables are the error/succees variables

 

<?php

//...A whole lotta ommitted code

	print   "<script type='text/javascript'>



			$('#pic_upload_feedback', window.parent.document).html(<div>".$_SESSION['error'].$_SESSION['pic_upload_success']."</div> );




		</script>";



?>

 

 

Thanks.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.