处理 POST 请求时的进度图标
初始条件如下:
后端:用于文件上传的servlet;
UI:表单,提交用于文件上传的 servlet:
<iframe id="uploadFrame" name="uploadFrame"></iframe>
<form enctype="multipart/form-data" method="post" target="uploadFrame"
action="<%= request.getContextPath() %>/uploadFile?
portletId=${portletId}&remoteFolder=${remoteFolder}">
...
</form>
单击此表单的提交按钮时,文件上传正在进行进行并且POST请求对应的是处理(可以在FireBug中跟踪)。
是否可以根据正在处理的 POST 请求绘制进度图标?
我的意思是,如果 POST 正在处理,则该网页应显示进度 .gif 图标。
也许,可以使用 Prototype lib 的 Ajax.PeriodicalUpdater 功能或其他解决方案吗?
不管怎样,看起来,没有ajax是不可能的。
感谢您的帮助。
There are next initial conditions:
Backend: servlet for file uploading;
UI: form, that submits servlet for file upload:
<iframe id="uploadFrame" name="uploadFrame"></iframe>
<form enctype="multipart/form-data" method="post" target="uploadFrame"
action="<%= request.getContextPath() %>/uploadFile?
portletId=${portletId}&remoteFolder=${remoteFolder}">
...
</form>
When submit button for this form is clicked, that file uploading is in progress and POST request correspondingly is processing (may track in FireBug).
Is it possible to draw progress icon dependently on this POST request is processing?
I mean,that if POST is processing, that web page should show progress .gif icon.
Perhaps,it's possible with Ajax.PeriodicalUpdater function of Prototype lib or some other solution?
Anyway, looks like, it's impossible to do without ajax.
Thanks fo any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
像 Prototype 或 JQuery 这样的东西可能有一个更干净的解决方案,但在普通的旧 JavaScript 中,应该可以根据表单提交来控制进度图标的可见性(或向 DOM 添加新的进度图标。这是一个简单的示例。您可能希望在现实世界中对此进行一些清理,以避免出现诸如内联样式之类的丑陋内容:
Parent.htm
SubmitResponse.htm(上传表单提交到的页面)
Something like Prototype or JQuery might have a cleaner solution, but in plain old javascript it should be possible to control the visibility of a progress icon based on the form submission (or add a new progress icon to the DOM. Here's a quick example. You'd probably want to clean this up a bit in the real world to avoid ugly stuff like inline styles:
Parent.htm
SubmitResponse.htm (the page your upload form submits to)
在之前的项目中,我使用 jQuery 在加载 iframe 之后和 ajax post 之前将后期绑定加载处理程序附加到 iframe。
一旦回发完成,您的回调函数就会负责拆除 gif。
In a previous project I used jQuery to attach a late bound load handler to the iframe after it had been loaded and before the ajax post.
Once the postback is completed your callback function takes care of tearing down the gif.
这是一个很好的链接:http://pixeline.be/experiments/jqUploader/
Here's a nice link to you: http://pixeline.be/experiments/jqUploader/