如何添加“正在加载...请稍候...”特征?
我的网站上有一个非常简单的表格,显示不同的 URL。我有一个输入字段,可以在其中输入 URL,然后单击“提交”以添加其他 URL。
但是,我想为此添加 MD5 抓取功能,使用 @md5_file();在将 URL 添加到数据库之前,获取 URL 的 MD5 并检查以确保它是应有的 MD5。然而,它可能需要几秒钟的时间来获取 MD5 并进行比较,所以我想在比较时添加一些文本,例如“正在处理...请稍候...”,然后一次比较后我希望该文本消失。
我以前从未这样做过,或者即使打算这样做,所以我不知道从哪里开始。我将继续将 javascript 作为此标记,因为我猜测这将用 javascript 完成,但我真的不知道。我不认为 PHP 可以做到这一点,但我还是不知道。
有什么建议吗?
I have a very simple table on my website, that displays different URL's. I have an input field where I can type in a URL and click 'Submit' to add additional URL's.
However, I want to add an MD5 grabbing feature to this, using @md5_file(); to grab the MD5 of the URL and check to make sure it's the MD5 it should be, before adding it to the database. However it may take a few seconds for it to grab the MD5 and compare it, so I would like to add a little bit of text, like "Processing...Please wait..." while it does the comparing, and then once it's compared I want that text to go away.
I've never done this before, or even though about doing it so I have no idea where to start. I'll go ahead and put javascript as a tag for this, since I'm guessing it would be done with javascript, but I really have no idea. I don't think it's possible with PHP, but again, I have no idea.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会使用 jQuery。下面是示例:
在您的 javascript 代码中:
以及您的 HTML
这是一个参考: http://api .jquery.com/jQuery.ajax/
I would use jQuery. Here is the example:
In your javascript code:
And your HTML
Here is a reference: http://api.jquery.com/jQuery.ajax/
http://www.ajaxload.info/是一个非常有趣的地方。将此图像设置为可见和不可见
http://www.ajaxload.info/ is a very interesting place. Turn this image visible and invisible
我这样做的方式是在执行 AJAX 帖子的函数中,我显示一个对话框(在帖子之前),在 ajax 帖子之后,我隐藏它。任何模式对话框都可以(我喜欢 jQuery,因为我通常使用与我正在使用的任何网站设计相匹配的主题)。这样做的问题是,有时帖子不会花很长时间,而且看起来很紧张。如果是这种情况,在页面中间放置一个带有突出颜色的简单 div 就足够了。
The way I have done it is in the function where I do an AJAX post I show a dialog (before the post) and after the ajax post, I hide it. Any modal dialog will do (I like jQuery's since I commonly use a theme that goes with whatever site design I am using). The problem with this is that sometimes the post doesn't take very long and it looks jittery. If that is the case, a simple div in the middle of the page with coloring that stands out will suffice.