Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
f9d41ac6
Commit
f9d41ac6
authored
Oct 28, 2013
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #14379: AJAX requests on unload
parent
ebabb334
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
4 deletions
+37
-4
xhr.js
src/ajax/xhr.js
+2
-4
onunload.html
test/data/ajax/onunload.html
+30
-0
ajax.js
test/unit/ajax.js
+5
-0
No files found.
src/ajax/xhr.js
View file @
f9d41ac6
...
@@ -18,18 +18,16 @@ var xhrSupported = jQuery.ajaxSettings.xhr(),
...
@@ -18,18 +18,16 @@ var xhrSupported = jQuery.ajaxSettings.xhr(),
// #1450: sometimes IE returns 1223 when it should be 204
// #1450: sometimes IE returns 1223 when it should be 204
1223
:
204
1223
:
204
},
},
// Support: IE9
// We need to keep track of outbound xhr and abort them manually
// because IE is not smart enough to do it all by itself
xhrId
=
0
,
xhrId
=
0
,
xhrCallbacks
=
{};
xhrCallbacks
=
{};
// Support: IE9
// Open requests must be manually aborted on unload (#5280)
if
(
window
.
ActiveXObject
)
{
if
(
window
.
ActiveXObject
)
{
jQuery
(
window
).
on
(
"unload"
,
function
()
{
jQuery
(
window
).
on
(
"unload"
,
function
()
{
for
(
var
key
in
xhrCallbacks
)
{
for
(
var
key
in
xhrCallbacks
)
{
xhrCallbacks
[
key
]();
xhrCallbacks
[
key
]();
}
}
xhrCallbacks
=
undefined
;
});
});
}
}
...
...
test/data/ajax/onunload.html
0 → 100644
View file @
f9d41ac6
<!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>
test/unit/ajax.js
View file @
f9d41ac6
...
@@ -1522,6 +1522,11 @@ module( "ajax", {
...
@@ -1522,6 +1522,11 @@ module( "ajax", {
}
}
}
);
}
);
testIframeWithCallback
(
"#14379 - jQuery.ajax() on unload"
,
"ajax/onunload.html"
,
function
(
status
)
{
expect
(
1
);
strictEqual
(
status
,
"success"
,
"Request completed"
);
});
//----------- jQuery.ajaxPrefilter()
//----------- jQuery.ajaxPrefilter()
ajaxTest
(
"jQuery.ajaxPrefilter() - abort"
,
1
,
{
ajaxTest
(
"jQuery.ajaxPrefilter() - abort"
,
1
,
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment