mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fix #14379: AJAX requests on unload
(cherry picked from commit f9d41ac641
)
Conflicts:
src/ajax/xhr.js
This commit is contained in:
parent
d8576139c1
commit
26705c6c5b
30
test/data/ajax/onunload.html
Normal file
30
test/data/ajax/onunload.html
Normal file
@ -0,0 +1,30 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
||||
<title>onunload ajax requests (#14379)</title>
|
||||
<script src="../../jquery.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<form id="navigate" action="about:blank"></form>
|
||||
<script>
|
||||
jQuery( window ).on( "unload", function() {
|
||||
var ajaxStatus;
|
||||
jQuery.ajax({
|
||||
url: "../name.html",
|
||||
async: false,
|
||||
complete: function( xhr, status ) {
|
||||
ajaxStatus = status;
|
||||
}
|
||||
});
|
||||
parent.iframeCallback( ajaxStatus );
|
||||
});
|
||||
|
||||
jQuery(function() {
|
||||
setTimeout(function() {
|
||||
document.getElementById( "navigate" ).submit();
|
||||
}, 0 );
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1565,6 +1565,11 @@ module( "ajax", {
|
||||
}
|
||||
} );
|
||||
|
||||
testIframeWithCallback( "#14379 - jQuery.ajax() on unload", "ajax/onunload.html", function( status ) {
|
||||
expect( 1 );
|
||||
strictEqual( status, "success", "Request completed" );
|
||||
});
|
||||
|
||||
//----------- jQuery.ajaxPrefilter()
|
||||
|
||||
ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, {
|
||||
|
Loading…
Reference in New Issue
Block a user