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
fdd4101f
Commit
fdd4101f
authored
Feb 01, 2011
by
Anton Kovalyov
Committed by
Anton M
Feb 01, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #7945. Make jQuery.param() serialize plain objects with a property named jquery correctly.
parent
fa4c9098
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
ajax.js
src/ajax.js
+1
-1
ajax.js
test/unit/ajax.js
+6
-1
No files found.
src/ajax.js
View file @
fdd4101f
...
@@ -698,7 +698,7 @@ jQuery.extend({
...
@@ -698,7 +698,7 @@ jQuery.extend({
}
}
// If an array was passed in, assume that it is an array of form elements.
// If an array was passed in, assume that it is an array of form elements.
if
(
jQuery
.
isArray
(
a
)
||
a
.
jquery
)
{
if
(
jQuery
.
isArray
(
a
)
||
(
a
.
jquery
&&
!
jQuery
.
isPlainObject
(
a
)
)
)
{
// Serialize the form elements
// Serialize the form elements
jQuery
.
each
(
a
,
function
()
{
jQuery
.
each
(
a
,
function
()
{
add
(
this
.
name
,
this
.
value
);
add
(
this
.
name
,
this
.
value
);
...
...
test/unit/ajax.js
View file @
fdd4101f
...
@@ -930,7 +930,7 @@ test("serialize()", function() {
...
@@ -930,7 +930,7 @@ test("serialize()", function() {
});
});
test
(
"jQuery.param()"
,
function
()
{
test
(
"jQuery.param()"
,
function
()
{
expect
(
2
3
);
expect
(
2
5
);
equals
(
!
jQuery
.
ajaxSettings
.
traditional
,
true
,
"traditional flag, falsy by default"
);
equals
(
!
jQuery
.
ajaxSettings
.
traditional
,
true
,
"traditional flag, falsy by default"
);
...
@@ -965,6 +965,11 @@ test("jQuery.param()", function() {
...
@@ -965,6 +965,11 @@ test("jQuery.param()", function() {
equals
(
jQuery
.
param
({
"foo"
:
{
"bar"
:
[],
foo
:
1
}
}),
"foo%5Bbar%5D=&foo%5Bfoo%5D=1"
,
"Empty array param"
);
equals
(
jQuery
.
param
({
"foo"
:
{
"bar"
:
[],
foo
:
1
}
}),
"foo%5Bbar%5D=&foo%5Bfoo%5D=1"
,
"Empty array param"
);
equals
(
jQuery
.
param
({
"foo"
:
{
"bar"
:
{}}
}),
"foo%5Bbar%5D="
,
"Empty object param"
);
equals
(
jQuery
.
param
({
"foo"
:
{
"bar"
:
{}}
}),
"foo%5Bbar%5D="
,
"Empty object param"
);
// #7945
equals
(
jQuery
.
param
({
"jquery"
:
"1.4.2"
}),
"jquery=1.4.2"
,
"Check that object with a jQuery property get serialized correctly"
);
equals
(
jQuery
.
param
(
jQuery
(
"#form :input"
)),
"action=Test&text2=Test&radio1=on&radio2=on&check=on&=on&hidden=&foo%5Bbar%5D=&name=name&search=search&button=&=foobar&select1=&select2=3&select3=1&select4=1&select5=3"
,
"Make sure jQuery objects are properly serialized"
);
jQuery
.
ajaxSetup
({
traditional
:
true
});
jQuery
.
ajaxSetup
({
traditional
:
true
});
var
params
=
{
foo
:
"bar"
,
baz
:
42
,
quux
:
"All your base are belong to us"
};
var
params
=
{
foo
:
"bar"
,
baz
:
42
,
quux
:
"All your base are belong to us"
};
...
...
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