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
ba9e0fc1
Commit
ba9e0fc1
authored
Sep 21, 2010
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a different workaround for detecting when Opera finds a status 304 page. Fixes #6060.
parent
3a0a3528
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
3 deletions
+18
-3
ajax.js
src/ajax.js
+5
-3
notmodified.php
test/data/notmodified.php
+1
-0
ajax.js
test/unit/ajax.js
+12
-0
No files found.
src/ajax.js
View file @
ba9e0fc1
...
@@ -629,9 +629,11 @@ jQuery.extend( jQuery.ajax, {
...
@@ -629,9 +629,11 @@ jQuery.extend( jQuery.ajax, {
try
{
try
{
// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
return
!
xhr
.
status
&&
location
.
protocol
===
"file:"
||
return
!
xhr
.
status
&&
location
.
protocol
===
"file:"
||
// Opera returns 0 when status is 304
(
xhr
.
status
>=
200
&&
xhr
.
status
<
300
)
||
(
xhr
.
status
>=
200
&&
xhr
.
status
<
300
)
||
xhr
.
status
===
304
||
xhr
.
status
===
1223
||
xhr
.
status
===
0
;
xhr
.
status
===
304
||
xhr
.
status
===
1223
||
// Opera returns a status of 0 for redirects -
// We can detect this by the fact that Opera also doesn't return any headers
xhr
.
status
===
0
&&
!
xhr
.
getAllResponseHeaders
();
}
catch
(
e
)
{}
}
catch
(
e
)
{}
return
false
;
return
false
;
...
@@ -651,7 +653,7 @@ jQuery.extend( jQuery.ajax, {
...
@@ -651,7 +653,7 @@ jQuery.extend( jQuery.ajax, {
}
}
// Opera returns 0 when status is 304
// Opera returns 0 when status is 304
return
xhr
.
status
===
304
||
xhr
.
status
===
0
;
return
xhr
.
status
===
304
||
xhr
.
status
===
0
&&
!
xhr
.
getAllResponseHeaders
()
;
},
},
httpData
:
function
(
xhr
,
type
,
s
)
{
httpData
:
function
(
xhr
,
type
,
s
)
{
...
...
test/data/notmodified.php
0 → 100644
View file @
ba9e0fc1
<?php
header
(
'HTTP/1.0 304 Not Modified'
);
exit
;
?>
test/unit/ajax.js
View file @
ba9e0fc1
...
@@ -68,6 +68,18 @@ test("jQuery.ajax() - error callbacks", function() {
...
@@ -68,6 +68,18 @@ test("jQuery.ajax() - error callbacks", function() {
});
});
});
});
test
(
".ajax() - 304"
,
function
()
{
expect
(
1
);
stop
();
jQuery
.
ajax
({
url
:
url
(
"data/notmodified.php"
),
success
:
function
(){
ok
(
true
,
"304 ok"
);
},
error
:
function
(){
ok
(
false
,
"304 not ok "
);
},
complete
:
function
(
xhr
){
start
();
}
});
});
test
(
".load()) - 404 error callbacks"
,
function
()
{
test
(
".load()) - 404 error callbacks"
,
function
()
{
expect
(
6
);
expect
(
6
);
stop
();
stop
();
...
...
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