中止AJAX请求
- <html>
- <head>
- <mce:script type="text/<a href="http:
- var currentAjax = null;
- function startAjax(){
-
- currentAjax = $.ajax({
- type:'POST',
- beforeSend:function(){},
- url:'test.<a href="http://lib.csdn.net/base/php" class='replace_word' title="PHP知识库" target='_blank' style='color:#df3434; font-weight:bold;'>PHP</a>',
- data:'username=xxx',
- dataType:'JSON',
- error:function(){alert('error')},
- success:function(data){alert(data)}
- });
- }
- function stopAjax(){
-
- if(currentAjax) {currentAjax.abort();}
- }
- </head>
- <body>
- <input type="button" value="触发请求" onclick="startAjax()" />
- <input type="button" value="停止请求" onclick="stopAjax()" />
- </body>
- </html>
原文地址:https://www.cnblogs.com/lx-doit/p/6014995.html