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
54867a98
Commit
54867a98
authored
May 15, 2008
by
Ariel Flesler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jquery ajax: caching repetive conversions/checks for settings.type in $.ajax.
parent
31f22f24
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
ajax.js
src/ajax.js
+9
-8
No files found.
src/ajax.js
View file @
54867a98
...
@@ -165,19 +165,20 @@ jQuery.extend({
...
@@ -165,19 +165,20 @@ jQuery.extend({
lastModified
:
{},
lastModified
:
{},
ajax
:
function
(
s
)
{
ajax
:
function
(
s
)
{
var
jsonp
,
jsre
=
/=
\?(
&|$
)
/g
,
status
,
data
;
// Extend the settings, but re-extend 's' so that it can be
// Extend the settings, but re-extend 's' so that it can be
// checked again later (in the test suite, specifically)
// checked again later (in the test suite, specifically)
s
=
jQuery
.
extend
(
true
,
s
,
jQuery
.
extend
(
true
,
{},
jQuery
.
ajaxSettings
,
s
));
s
=
jQuery
.
extend
(
true
,
s
,
jQuery
.
extend
(
true
,
{},
jQuery
.
ajaxSettings
,
s
));
var
jsonp
,
jsre
=
/=
\?(
&|$
)
/g
,
status
,
data
,
type
=
s
.
type
.
toUpperCase
();
// convert data if not already a string
// convert data if not already a string
if
(
s
.
data
&&
s
.
processData
&&
typeof
s
.
data
!=
"string"
)
if
(
s
.
data
&&
s
.
processData
&&
typeof
s
.
data
!=
"string"
)
s
.
data
=
jQuery
.
param
(
s
.
data
);
s
.
data
=
jQuery
.
param
(
s
.
data
);
// Handle JSONP Parameter Callbacks
// Handle JSONP Parameter Callbacks
if
(
s
.
dataType
==
"jsonp"
)
{
if
(
s
.
dataType
==
"jsonp"
)
{
if
(
s
.
type
.
toLowerCase
()
==
"get
"
)
{
if
(
type
==
"GET
"
)
{
if
(
!
s
.
url
.
match
(
jsre
)
)
if
(
!
s
.
url
.
match
(
jsre
)
)
s
.
url
+=
(
s
.
url
.
match
(
/
\?
/
)
?
"&"
:
"?"
)
+
(
s
.
jsonp
||
"callback"
)
+
"=?"
;
s
.
url
+=
(
s
.
url
.
match
(
/
\?
/
)
?
"&"
:
"?"
)
+
(
s
.
jsonp
||
"callback"
)
+
"=?"
;
}
else
if
(
!
s
.
data
||
!
s
.
data
.
match
(
jsre
)
)
}
else
if
(
!
s
.
data
||
!
s
.
data
.
match
(
jsre
)
)
...
@@ -214,7 +215,7 @@ jQuery.extend({
...
@@ -214,7 +215,7 @@ jQuery.extend({
if
(
s
.
dataType
==
"script"
&&
s
.
cache
==
null
)
if
(
s
.
dataType
==
"script"
&&
s
.
cache
==
null
)
s
.
cache
=
false
;
s
.
cache
=
false
;
if
(
s
.
cache
===
false
&&
s
.
type
.
toLowerCase
()
==
"get
"
)
{
if
(
s
.
cache
===
false
&&
type
==
"GET
"
)
{
var
ts
=
now
();
var
ts
=
now
();
// try replacing _= if it is there
// try replacing _= if it is there
var
ret
=
s
.
url
.
replace
(
/
(\?
|&
)
_=.*
?(
&|$
)
/
,
"$1_="
+
ts
+
"$2"
);
var
ret
=
s
.
url
.
replace
(
/
(\?
|&
)
_=.*
?(
&|$
)
/
,
"$1_="
+
ts
+
"$2"
);
...
@@ -223,7 +224,7 @@ jQuery.extend({
...
@@ -223,7 +224,7 @@ jQuery.extend({
}
}
// If data is available, append data to url for get requests
// If data is available, append data to url for get requests
if
(
s
.
data
&&
s
.
type
.
toLowerCase
()
==
"get
"
)
{
if
(
s
.
data
&&
type
==
"GET
"
)
{
s
.
url
+=
(
s
.
url
.
match
(
/
\?
/
)
?
"&"
:
"?"
)
+
s
.
data
;
s
.
url
+=
(
s
.
url
.
match
(
/
\?
/
)
?
"&"
:
"?"
)
+
s
.
data
;
// IE likes to send both get and post data, prevent this
// IE likes to send both get and post data, prevent this
...
@@ -239,7 +240,7 @@ jQuery.extend({
...
@@ -239,7 +240,7 @@ jQuery.extend({
// If we're requesting a remote document
// If we're requesting a remote document
// and trying to load JSON or Script with a GET
// and trying to load JSON or Script with a GET
if
(
s
.
dataType
==
"script"
&&
s
.
type
.
toLowerCase
()
==
"get
"
if
(
s
.
dataType
==
"script"
&&
type
==
"GET
"
&&
remote
.
test
(
s
.
url
)
&&
remote
.
exec
(
s
.
url
)[
1
]
!=
location
.
host
){
&&
remote
.
test
(
s
.
url
)
&&
remote
.
exec
(
s
.
url
)[
1
]
!=
location
.
host
){
var
head
=
document
.
getElementsByTagName
(
"head"
)[
0
];
var
head
=
document
.
getElementsByTagName
(
"head"
)[
0
];
var
script
=
document
.
createElement
(
"script"
);
var
script
=
document
.
createElement
(
"script"
);
...
@@ -278,9 +279,9 @@ jQuery.extend({
...
@@ -278,9 +279,9 @@ jQuery.extend({
// Open the socket
// Open the socket
// Passing null username, generates a login popup on Opera (#2865)
// Passing null username, generates a login popup on Opera (#2865)
if
(
s
.
username
)
if
(
s
.
username
)
xml
.
open
(
s
.
type
,
s
.
url
,
s
.
async
,
s
.
username
,
s
.
password
);
xml
.
open
(
type
,
s
.
url
,
s
.
async
,
s
.
username
,
s
.
password
);
else
else
xml
.
open
(
s
.
type
,
s
.
url
,
s
.
async
);
xml
.
open
(
type
,
s
.
url
,
s
.
async
);
// Need an extra try/catch for cross domain requests in Firefox 3
// Need an extra try/catch for cross domain requests in Firefox 3
try
{
try
{
...
...
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