jquery验证在远程请求时显示加载GIF
我正在使用 jquery 验证插件验证表单。我正在使用远程选项检查给定的用户名是否已在数据库中。一切都按预期进行,但我想在验证脚本请求服务器时显示加载 gif。有没有一种简单的方法可以完成此任务,或者我需要编辑插件 js 文件吗?不管怎样,这里是代表性的代码..
rules: {
user_name: {
alfanum:true,//custom method to check if alphanumeric
required: true,
minlength: 5,
remote: {url: "checkuser_custom.php",type:"GET",data:{cmd:"check"}}
}}
所以基本上我想在readystate 2期间显示一个ajax加载gif,
任何帮助表示赞赏!
I'm validating a form with the jquery validation plugin. I'm checking if a given username is already in db with the remote option. everything works like expected but I want to show a loading gif while the validation script is requesting the server. Is there an easy way to accomplish this or do I need to edit the plugin js file? anyways, here is the representative code..
rules: {
user_name: {
alfanum:true,//custom method to check if alphanumeric
required: true,
minlength: 5,
remote: {url: "checkuser_custom.php",type:"GET",data:{cmd:"check"}}
}}
So basically I want to display an ajax loading gif during readystate 2
any help appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据 http://docs.jquery.com/Plugins/Validation/Methods/remote 远程参数是一个完整的 jQuery.ajax 设置对象。请参阅 http://api.jquery.com/jQuery.ajax 了解实现细节。
According to http://docs.jquery.com/Plugins/Validation/Methods/remote the remote param is a full jQuery.ajax settings object. See http://api.jquery.com/jQuery.ajax for implementation details.
您可以添加如下方法:
然后使用它几乎与“远程”相同,如下所示:
You can add a method like below:
Then use it almost same as "remote", like below: