donglusou3335 2011-11-30 11:55
浏览 25
已采纳

使用iframe上传PHP文件 - 宣布上传的开始和结束

so I have a PHP iframe (ajax) file uploader. I would like to display a loading message when submit is clicked (easy on click event) and then once the file is uploaded, so when the iframe is loaded with the PHP response, vanish (jquery fadeOut) and an alert box pop up saying the file is uploaded. what would be the easiest way to go about this?

  • 写回答

1条回答 默认 最新

  • donglu8779 2011-11-30 11:57
    关注

    You can attach an event handler to load on the iframe and put your fade out logic in there.

    Edit 2: Some sample code (changed from ready to load)

    <iframe name="process"></iframe>
    
    <form method="post" action="upload.php" target="process" enctype="multipart/form-data" onsubmit="Upload.start()">
        <input type="file" name="file" />
        <input type="submit" value="Upload" />
    </form>
    
    <script>
        var Upload = function() {
    
            $(function() {
                $('iframe[name=process]').load(function() {
                // finished uploading file
                    $('.loading-div').hide('slow', function() {
                        alert('Your file has been successfully uploaded.');
                    });
                });
            });
    
            return {
                start: function() {
                    $('.loading-div').show();
                }
            }
        }();  
    </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误