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
aee221d3
Commit
aee221d3
authored
Dec 04, 2007
by
David Serduke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #1999 by replacing the 'no-cache' parameter if it is there instead of just appending.
parent
701b072e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
ajax.js
src/ajax.js
+7
-2
ajax.js
test/unit/ajax.js
+31
-1
No files found.
src/ajax.js
View file @
aee221d3
...
@@ -197,8 +197,13 @@ jQuery.extend({
...
@@ -197,8 +197,13 @@ 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
&&
s
.
type
.
toLowerCase
()
==
"get"
)
{
s
.
url
+=
(
s
.
url
.
match
(
/
\?
/
)
?
"&"
:
"?"
)
+
"_="
+
(
new
Date
()).
getTime
();
var
ts
=
(
new
Date
()).
getTime
();
// try replacing _= if it is there
var
ret
=
s
.
url
.
replace
(
/
(\?
|&
)
_=.*
(
&|$
)
/
,
"$1_="
+
ts
+
"$2"
);
// if nothing was replaced, add timestamp to the end
s
.
url
=
ret
+
((
ret
==
s
.
url
)
?
(
s
.
url
.
match
(
/
\?
/
)
?
"&"
:
"?"
)
+
"_="
+
ts
:
""
);
}
// 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
&&
s
.
type
.
toLowerCase
()
==
"get"
)
{
...
...
test/unit/ajax.js
View file @
aee221d3
...
@@ -236,6 +236,36 @@ test("pass-through request object", function() {
...
@@ -236,6 +236,36 @@ test("pass-through request object", function() {
ok
(
$
.
ajax
({
url
:
url
(
target
),
success
:
success
}),
"generic"
);
ok
(
$
.
ajax
({
url
:
url
(
target
),
success
:
success
}),
"generic"
);
});
});
test
(
"ajax cache"
,
function
()
{
expect
(
18
);
stop
();
var
count
=
0
;
$
(
"#firstp"
).
bind
(
"ajaxSuccess"
,
function
(
e
,
xml
,
s
)
{
var
re
=
/_=
(
.*
?)(
&|$
)
/g
;
var
oldOne
=
null
;
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
var
ret
=
re
.
exec
(
s
.
url
);
if
(
!
ret
)
{
break
;
}
oldOne
=
ret
[
1
];
}
equals
(
i
,
1
,
"Test to make sure only one 'no-cache' parameter is there"
);
ok
(
oldOne
!=
"tobereplaced555"
,
"Test to be sure parameter (if it was there) was replaced"
);
if
(
++
count
==
6
)
start
();
});
ok
(
$
.
ajax
({
url
:
"data/text.php"
,
cache
:
false
}),
"test with no parameters"
);
ok
(
$
.
ajax
({
url
:
"data/text.php?pizza=true"
,
cache
:
false
}),
"test with 1 parameter"
);
ok
(
$
.
ajax
({
url
:
"data/text.php?_=tobereplaced555"
,
cache
:
false
}),
"test with _= parameter"
);
ok
(
$
.
ajax
({
url
:
"data/text.php?pizza=true&_=tobereplaced555"
,
cache
:
false
}),
"test with 1 parameter plus _= one"
);
ok
(
$
.
ajax
({
url
:
"data/text.php?_=tobereplaced555&tv=false"
,
cache
:
false
}),
"test with 1 parameter plus _= one before it"
);
ok
(
$
.
ajax
({
url
:
"data/text.php?name=David&_=tobereplaced555&washere=true"
,
cache
:
false
}),
"test with 2 parameters surrounding _= one"
);
});
test
(
"global ajaxSettings"
,
function
()
{
test
(
"global ajaxSettings"
,
function
()
{
expect
(
3
);
expect
(
3
);
...
...
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