Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
6151cbde
Commit
6151cbde
authored
15 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
#646694
by rfay: Added much more meaningful error reporting to AJAX.
parent
f8e75ebd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc/drupal.js
+17
-9
17 additions, 9 deletions
misc/drupal.js
with
17 additions
and
9 deletions
misc/drupal.js
+
17
−
9
View file @
6151cbde
...
...
@@ -316,18 +316,26 @@ Drupal.getSelection = function (element) {
* Build an error message from an AJAX response.
*/
Drupal
.
ajaxError
=
function
(
xmlhttp
,
uri
)
{
if
(
xmlhttp
.
status
==
200
||
(
xmlhttp
.
status
==
500
&&
xmlhttp
.
statusText
==
'
Service unavailable (with message)
'
))
{
if
(
$
.
trim
(
xmlhttp
.
responseText
))
{
var
message
=
Drupal
.
t
(
"
An error occurred.
\n
Path: @uri
\n
Message: !text
"
,
{
'
@uri
'
:
uri
,
'
!text
'
:
xmlhttp
.
responseText
});
}
else
{
var
message
=
Drupal
.
t
(
"
An error occurred.
\n
Path: @uri
\n
(no information available).
"
,
{
'
@uri
'
:
uri
});
}
var
statusCode
,
statusText
,
pathText
,
responseText
,
readyStateText
,
message
;
if
(
xmlhttp
.
status
)
{
statusCode
=
"
\n
"
+
Drupal
.
t
(
"
An AJAX HTTP error occurred.
"
)
+
"
\n
"
+
Drupal
.
t
(
"
HTTP Result Code: !status
"
,
{
'
!status
'
:
xmlhttp
.
status
});
}
else
{
var
message
=
Drupal
.
t
(
"
An HTTP error @status occurred.
\n
Path: @uri
"
,
{
'
@uri
'
:
uri
,
'
@status
'
:
xmlhttp
.
status
}
);
statusCode
=
"
\n
"
+
Drupal
.
t
(
"
An AJAX HTTP request terminated abnormally.
"
);
}
return
message
.
replace
(
/
\n
/g
,
'
<br />
'
);
statusCode
+=
"
\n
"
+
Drupal
.
t
(
"
Debugging information follows.
"
);
pathText
=
"
\n
"
+
Drupal
.
t
(
"
Path: !uri
"
,
{
'
!uri
'
:
uri
}
);
statusText
=
xmlhttp
.
statusText
?
(
"
\n
"
+
Drupal
.
t
(
"
StatusText: !statusText
"
,
{
'
!statusText
'
:
$
.
trim
(
xmlhttp
.
statusText
)}))
:
""
;
responseText
=
xmlhttp
.
responseText
?
(
"
\n
"
+
Drupal
.
t
(
"
ResponseText: !responseText
"
,
{
'
!responseText
'
:
$
.
trim
(
xmlhttp
.
responseText
)}))
:
""
;
// Make the responseText more readable by stripping HTML tags and newlines.
responseText
=
responseText
.
replace
(
/<
(
"
[^
"
]
*"|'
[^
'
]
*'|
[^
'">
])
*>/gi
,
""
);
responseText
=
responseText
.
replace
(
/
[\n]
+
\s
+/g
,
"
\n
"
);
// We don't need readyState except for status == 0.
readyStateText
=
xmlhttp
.
status
==
0
?
(
"
\n
"
+
Drupal
.
t
(
"
ReadyState: !readyState
"
,
{
'
!readyState
'
:
xmlhttp
.
readyState
}))
:
""
;
message
=
statusCode
+
pathText
+
statusText
+
responseText
+
readyStateText
;
return
message
;
};
// Class indicating that JS is enabled; used for styling purpose.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment