防止提交按钮多次点击,造成界面多次提交问题
1 <body> 2 <button onclick="save()">提交按钮</button> 3 <script> 4 var lock = false; 5 function save() { 6 if (lock) { 7 return false 8 } 9 lock = true; 10 $.ajax({ 11 type: "POST", 12 url: '', 13 data: {}, 14 dataType: "json", 15 //headers:{'Content-Type':'application/json'}, 16 success: function (res) { 17 lock = false; 18 19 }, 20 error: function () { 21 lock = false; 22 } 23 }) 24 25 } 26 </script> 27 28 </body>