jQuery验证显示加载GIF,而远程请求加载、jQuery、GIF

2023-09-10 20:06:06 作者:桑稚.

我验证与jQuery验证插件的形式。我检查,如果给定的用户名已在数据库与远程选项。一切工作像预期,但我想说明一个加载GIF,同时验证脚本请求的服务器。有没有一种简单的方法来做到这一点还是需要编辑插件的js文件?反正,这里是重presentative code ..

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"}}
   }}

所以基本上我想要的readyState 2时,显示一个ajax加载GIF

So basically I want to display an ajax loading gif during readystate 2

任何帮助AP preciated!

any help appreciated!

推荐答案

根据 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.