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
d515068e
Commit
d515068e
authored
Jan 09, 2011
by
jaubourg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #7868. ResponseText is now properly propagated for error callbacks.
parent
69497c3f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
9 deletions
+34
-9
ajax.js
src/ajax.js
+5
-0
xhr.js
src/ajax/xhr.js
+7
-9
errorWithText.php
test/data/errorWithText.php
+5
-0
ajax.js
test/unit/ajax.js
+17
-0
No files found.
src/ajax.js
View file @
d515068e
...
@@ -464,6 +464,11 @@ jQuery.extend({
...
@@ -464,6 +464,11 @@ jQuery.extend({
}
else
{
// if not success, mark it as an error
}
else
{
// if not success, mark it as an error
error
=
error
||
statusText
;
error
=
error
||
statusText
;
// Set responseText if needed
if
(
response
)
{
jXHR
.
responseText
=
response
;
}
}
}
// Set data for the fake xhr object
// Set data for the fake xhr object
...
...
src/ajax/xhr.js
View file @
d515068e
...
@@ -137,15 +137,13 @@ jQuery.ajax.transport( function( s , determineDataType ) {
...
@@ -137,15 +137,13 @@ jQuery.ajax.transport( function( s , determineDataType ) {
status
status
);
);
// Guess response if needed & update datatype accordingly
// Guess response & update dataType accordingly
if
(
status
>=
200
&&
status
<
300
)
{
response
=
response
=
determineDataType
(
determineDataType
(
s
,
s
,
xhr
.
getResponseHeader
(
"content-type"
),
xhr
.
getResponseHeader
(
"content-type"
),
xhr
.
responseText
,
xhr
.
responseText
,
xhr
.
responseXML
);
xhr
.
responseXML
);
}
}
}
// Call complete
// Call complete
...
...
test/data/errorWithText.php
0 → 100644
View file @
d515068e
<?php
header
(
"HTTP/1.0 400 Bad Request"
);
echo
"plain text message"
;
\ No newline at end of file
test/unit/ajax.js
View file @
d515068e
...
@@ -240,6 +240,23 @@ test("jQuery.ajax() - error callbacks", function() {
...
@@ -240,6 +240,23 @@ test("jQuery.ajax() - error callbacks", function() {
});
});
});
});
test
(
"jQuery.ajax() - responseText on error"
,
function
()
{
expect
(
1
);
stop
();
jQuery
.
ajax
({
url
:
url
(
"data/errorWithText.php"
),
error
:
function
(
xhr
)
{
strictEqual
(
xhr
.
responseText
,
"plain text message"
,
"Test jXHR.responseText is filled for HTTP errors"
);
},
complete
:
function
()
{
start
();
}
});
});
test
(
".ajax() - headers"
,
function
()
{
test
(
".ajax() - headers"
,
function
()
{
expect
(
2
);
expect
(
2
);
...
...
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