1

我不知道如何解释,但我会尽力而为......我正在尝试正常提交表单,但请求结果将显示在 iframe 中。一切顺利到这里。我想要做的(如果可能的话)是动画形式将消息放入其中(如“发送......”)直到 iframe 加载响应。我现在很困惑,但看看我的文件:

索引.php

我已经省略了标题,因为它是如此明显。

<form enctype="multipart/form-data" method="post" action="upload.php" target="my_iframe" id="form-upload">
    Choose your file here:
    <input name="uploaded_file" type="file"/>
    <input id="send-button" type="submit" value="Subir imagen"/>
</form>


<IFRAME name="my_iframe" SRC="upload.php" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0"></iframe>

<script type="text/javascript">
    $(document).ready(function(){
        $('#send-button').sendImage({formid: "form-upload"});
    });
</script>

上传.php

只是为了测试porpuses。

<?php
if( isset($_FILES['uploaded_file']) )
    echo "image sent";

动画.js

这就是我正在处理的地方。因为当我访问时,index.php总是sending...会显示表单元素的实例。

var conf;

jQuery.fn.sendImage = function(args) {
    conf = $.extend( {
    }, args);


    this.on('click', function(e){
        e.preventDefault();
        $('#'+conf.formid).submit();
        $('#'+conf.formid).html('sending...');
    });

}
4

1 回答 1

1

Once a form is submitted, all processing on the current page stops. Anything you do must be BEFORE you actually submit the form. You alternative is to submit via AJAX.

于 2013-02-06T16:31:06.033 回答