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
98c6c4b2
Commit
98c6c4b2
authored
Jan 09, 2011
by
jaubourg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a simple cache for xhr objects in the xhr transport.
parent
368f2441
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
xhr.js
src/ajax/xhr.js
+8
-1
No files found.
src/ajax/xhr.js
View file @
98c6c4b2
...
@@ -6,6 +6,9 @@ var // Next fake timer id
...
@@ -6,6 +6,9 @@ var // Next fake timer id
// Callbacks hashtable
// Callbacks hashtable
xhrs
=
{},
xhrs
=
{},
// XHR pool
xhrPool
=
[],
// #5280: see end of file
// #5280: see end of file
xhrUnloadAbortMarker
=
[];
xhrUnloadAbortMarker
=
[];
...
@@ -21,7 +24,7 @@ jQuery.ajax.transport( function( s , determineDataType ) {
...
@@ -21,7 +24,7 @@ jQuery.ajax.transport( function( s , determineDataType ) {
send
:
function
(
headers
,
complete
)
{
send
:
function
(
headers
,
complete
)
{
var
xhr
=
s
.
xhr
(),
var
xhr
=
xhrPool
.
pop
()
||
s
.
xhr
(),
handle
;
handle
;
// Open the socket
// Open the socket
...
@@ -53,6 +56,8 @@ jQuery.ajax.transport( function( s , determineDataType ) {
...
@@ -53,6 +56,8 @@ jQuery.ajax.transport( function( s , determineDataType ) {
try
{
try
{
xhr
.
send
(
(
s
.
hasContent
&&
s
.
data
)
||
null
);
xhr
.
send
(
(
s
.
hasContent
&&
s
.
data
)
||
null
);
}
catch
(
e
)
{
}
catch
(
e
)
{
// Store back in pool
xhrPool
.
push
(
xhr
);
complete
(
0
,
"error"
,
""
+
e
);
complete
(
0
,
"error"
,
""
+
e
);
return
;
return
;
}
}
...
@@ -64,10 +69,12 @@ jQuery.ajax.transport( function( s , determineDataType ) {
...
@@ -64,10 +69,12 @@ jQuery.ajax.transport( function( s , determineDataType ) {
if
(
callback
&&
(
abortStatusText
||
xhr
.
readyState
===
4
)
)
{
if
(
callback
&&
(
abortStatusText
||
xhr
.
readyState
===
4
)
)
{
// Do not listen anymore
// Do not listen anymore
// and Store back in pool
if
(
handle
)
{
if
(
handle
)
{
xhr
.
onreadystatechange
=
jQuery
.
noop
;
xhr
.
onreadystatechange
=
jQuery
.
noop
;
delete
xhrs
[
handle
];
delete
xhrs
[
handle
];
handle
=
undefined
;
handle
=
undefined
;
xhrPool
.
push
(
xhr
);
}
}
callback
=
0
;
callback
=
0
;
...
...
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