我不知道如何解释,但我会尽我所能。。。我正在尝试正常提交表单,但请求结果将显示在iframe中。这里一切都很好。我想做的(如果可能的话)是在iframe加载respose之前,将消息放入表单(如"sending…")。我现在这是如此困惑,但看看我的文件:
index.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
只是为了测试海豚。
<?php
if( isset($_FILES['uploaded_file']) )
echo "image sent";
animate.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...');
});
}
表单提交后,当前页面上的所有处理都将停止。你所做的任何事情都必须在你真正提交表单之前。你的选择是通过AJAX提交。