单击文件提交后加载图像 [英] loading image once file submit clicked

查看:62
本文介绍了单击文件提交后加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我允许注册用户向服务器提交图像.这里的问题是,如果图像的尺寸太大或用户的互联网连接速度很慢(许多人仍在此处使用拨号),则需要一段时间才能提交图像.并且某些用户在图像加载过程中一直单击提交"按钮.在一个网站上,我看到用户单击文件提交后,表单就会消失,并且会出现加载图像.我该如何使用jQuery?

I allow registered users to submit an image to the server. Problem here is, if image's size is too large or if user's internet connection is slow (many people still use dial up here) it take a while before its submitted. And some users keep clicking submit button while the image is in loading process. At one website, I saw that once user click on file submit, form disappears and loading image appears. How can I do that with jquery?

<form method="POST" ENCtype="multipart/form-data" action="imageupload.asp?Process=Add"> 
<p align="center"><b>--- Upload Image ---</b><br> 
<input type="FILE" size="23" name="FILE"> 
<input type=submit value="Upload"> 
</p> 
</form> 

推荐答案

只需将提交事件处理程序添加到表单中

just add a submit event handler to the form

例如像这样的东西

$('form').submit(function(){
  $(this).hide();
  $('#loadingimage').show();
});

其中loadingimage是具有ID loadingimage的元素,默认情况下处于隐藏状态.

where loadingimage is an element with the ID loadingimage and is by default hidden.

这篇关于单击文件提交后加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆