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
2d9979c7
Commit
2d9979c7
authored
Jun 22, 2006
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made some tweaks to the different AJAX callbacks.
parent
0fd3648d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
17 deletions
+13
-17
ajax.js
ajax/ajax.js
+13
-17
No files found.
ajax/ajax.js
View file @
2d9979c7
...
@@ -83,7 +83,7 @@ if ( jQuery.browser == "msie" )
...
@@ -83,7 +83,7 @@ if ( jQuery.browser == "msie" )
// Attach a bunch of functions for handling common AJAX events
// Attach a bunch of functions for handling common AJAX events
(
function
(){
(
function
(){
var
e
=
"ajaxStart
.ajaxComplete.ajaxError.
ajaxSuccess"
.
split
(
','
);
var
e
=
"ajaxStart
,ajaxStop,ajaxComplete,ajaxError,
ajaxSuccess"
.
split
(
','
);
for
(
var
i
=
0
;
i
<
e
.
length
;
i
++
){
(
function
(){
for
(
var
i
=
0
;
i
<
e
.
length
;
i
++
){
(
function
(){
var
o
=
e
[
i
];
var
o
=
e
[
i
];
...
@@ -105,6 +105,10 @@ jQuery.ajax = function( type, url, data, ret ) {
...
@@ -105,6 +105,10 @@ jQuery.ajax = function( type, url, data, ret ) {
url
=
type
.
url
;
url
=
type
.
url
;
type
=
type
.
type
;
type
=
type
.
type
;
}
}
// Watch for a new set of requests
if
(
!
jQuery
.
ajax
.
active
++
)
jQuery
.
event
.
trigger
(
"ajaxStart"
);
// Create the request object
// Create the request object
var
xml
=
new
XMLHttpRequest
();
var
xml
=
new
XMLHttpRequest
();
...
@@ -125,23 +129,8 @@ jQuery.ajax = function( type, url, data, ret ) {
...
@@ -125,23 +129,8 @@ jQuery.ajax = function( type, url, data, ret ) {
// Wait for a response to come back
// Wait for a response to come back
xml
.
onreadystatechange
=
function
(){
xml
.
onreadystatechange
=
function
(){
// Socket is openend
// The transfer is complete and the data is available
if
(
xml
.
readyState
==
1
)
{
// Increase counter
jQuery
.
ajax
.
active
++
;
// Show 'loader'
jQuery
.
event
.
trigger
(
"ajaxStart"
);
}
// Socket is closed and data is available
if
(
xml
.
readyState
==
4
)
{
if
(
xml
.
readyState
==
4
)
{
// Hide loader if needed
if
(
!
--
jQuery
.
ajax
.
active
)
{
jQuery
.
event
.
trigger
(
"ajaxComplete"
);
jQuery
.
ajax
.
active
=
0
}
// Make sure that the request was successful
// Make sure that the request was successful
if
(
jQuery
.
httpSuccess
(
xml
)
)
{
if
(
jQuery
.
httpSuccess
(
xml
)
)
{
...
@@ -159,6 +148,13 @@ jQuery.ajax = function( type, url, data, ret ) {
...
@@ -159,6 +148,13 @@ jQuery.ajax = function( type, url, data, ret ) {
// Fire the global callback
// Fire the global callback
jQuery
.
event
.
trigger
(
"ajaxError"
);
jQuery
.
event
.
trigger
(
"ajaxError"
);
}
}
// The request was completed
jQuery
.
event
.
trigger
(
"ajaxComplete"
);
// Handle the global AJAX counter
if
(
!
--
jQuery
.
ajax
.
active
)
jQuery
.
event
.
trigger
(
"ajaxStop"
);
// Process result
// Process result
if
(
ret
)
ret
(
xml
);
if
(
ret
)
ret
(
xml
);
...
...
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