标签:bsp 提交 back php color input turn tar 提交数据
//在按钮提交之后和AJAX提交之前将按钮设置为禁用 $("input[type=submit]").attr(‘disabled‘,true) $.ajax({ url:‘/post.php‘ data:{a:1,b,1} success:function(){ //在提交成功之后重新启用该按钮 $("input[type=submit]").attr(‘disabled‘,false) }, error: function(){ //即使AJAX失败也需要将按钮设置为可用状态,因为有可能是网络问题导致的失败,所以需要将按钮设置为可用 $("input[type=submit]").attr(‘disabled‘,false) } })
//设置一个对象来控制是否进入AJAX过程 var post_flag = false; function post(){ //如果正在提交则直接返回,停止执行 if(post_flag) return; //标记当前状态为正在提交状态 post_flag = true; $.ajax({//进入AJAX提交过程 url:‘/post.php‘ data:{a:1,b,1} success:function(){ post_flag =false; //在提交成功之后将标志标记为可提交状态 }, error: function(){ post_flag =false; //AJAX失败也需要将标志标记为可提交状态 } }) }
标签:bsp 提交 back php color input turn tar 提交数据
原文地址:http://www.cnblogs.com/tblj/p/6892208.html