I have a submit form that is sent to a hidden iframe. I try to call a function on the parent page from an iframe, but I get the error "top.stopUpload is not a function".
What is the right way to do this?
PARENT PAGE:
$(document).ready(function() { $('#document_upload').submit( function() { $('#upload_progress').show(); }); function stopUpload(success){ if (success == 1){ $('#result', window.parent.document).html( '<span class="msg">The file was uploaded successfully!<\/span>'); } else { $('#result', window.parent.document).html( '<span class="emsg">There was an error during file upload!<\/span>'); } $('#upload_progress').hide(); return true; } })
IFRAME:
$(document).ready(function() { top.stopUpload(<?php echo $result; ?>); }
source share