【问题标题】:Submit form with jQuery to iframe feedback when done?完成后使用 jQuery 提交表单到 iframe 反馈?
【发布时间】:2012-11-20 12:55:54
【问题描述】:

对于照片上传,我将表单提交到 iframe。

表格

<form method="post" enctype="multipart/form-data" action="upload_images.php" target="iframe_pp_upload" id="dd_form">
   <input type="file" id="dd_upload" name="file">
</form>

iframe

<iframe name="iframe_pp_upload" src="not-yet-submitted.php"></iframe>

jQuery

​​>
$('#dd_upload').change(function() {
  $('#dd_form').submit();
});

upload_images.php 上传图片。但是,上传完成后获得反馈的最佳方式是什么?

【问题讨论】:

    标签: php jquery ajax iframe


    【解决方案1】:

    在upload_images.php中做这个输出:

    file header......
        <script>
             window.parent.uploadReady(); 
        </script>
    
    .....
    

    并且在主窗口中,必须有一个js函数uploadReady(),在那里你可以为所欲为。

    function uploadReady() {
          alert("im in the parent window");
     }
    

    希望对你有帮助

    【讨论】:

    • 谢谢,凯。问题是,如果我在 iframe 中输出您的代码,警报将在页面加载时立即触发。我如何知道上传何时准备就绪?
    猜你喜欢
    • 1970-01-01
    • 2011-03-25
    • 2011-07-29
    • 2021-11-24
    • 2012-01-12
    • 1970-01-01
    • 2014-09-13
    • 1970-01-01
    • 2011-09-21
    相关资源
    最近更新 更多