oop*_*ops 11 javascript ajax jquery cancellation
In phonegap how to cancel an ajax request in program, I would like to set cancel button for control the request when it's too slow
$.ajax({
type: "GET",
url: url,
success: function(m) {
alert( "success");
}
});
Run Code Online (Sandbox Code Playgroud)
嗨它类似于使用jQuery的Abort Ajax请求,无论如何这可以帮助你
var ab = $.ajax({ type: "GET", url: url, success: function(m) { alert( "success"); } });
//kill the request
ab.abort()
Run Code Online (Sandbox Code Playgroud)
Store the promise interface returned from ajax request in a global variable and abort it on cancel click
var result = $.ajax({ type: "GET", url: url, success: function(m) { alert( "success"); } });
$('#cancel').click(function() {
result.abort();
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2272 次 |
| 最近记录: |