Side navigation
#7945 closed bug (fixed)
Opened January 11, 2011 07:39AM UTC
Closed February 01, 2011 11:34PM UTC
Last modified March 09, 2012 03:47PM UTC
jQuery.param thinks that { jquery: "1.4.2" } is a jQuery object
Reported by: | anton@kovalyov.net | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 1.5.1 |
Component: | ajax | Version: | 1.5 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I stumbled upon a bug where .param thought that { jquery: "1.4.2" } is a jQuery object and tried to iterate over it as it was an array. The result was undefined=undefined instead of jquery=1.4.2.
I made a commit fixing the problem and opened a pull request here: https://github.com/jquery/jquery/pull/174 but it was closed.
I was asked to clarify about the use case so here is the real world example. I am working on a feature that will collect some statistical data from pages where our widget is installed. I started with popular frameworks, and my code sends key/value data where key is a framework name and value is its version.
Now every time I try to send something like { "jquery": "1.4.2" } via .ajax, the server gets undefined=undefined in its POST data. And that applies to any dictionary that has "jquery" string as a key.
The second comment was that we can't use instanceof
since there is a possibility that an object was created by some other jQuery instance. That makes sense. My initial approach was to check if a.jquery is a function. That covers multiple jQuery instances problem.
As Paul said in the comment to the pull request above, I got some helpful advise from Ben Alman so we might want his feedback on this issue as well.
I can make another pull request once we agree on the approach here.
Anton
Attachments (0)
Change History (6)
Changed January 11, 2011 07:47AM UTC by comment:1
Changed January 14, 2011 10:26PM UTC by comment:2
So, I went ahead and made another (now proper) pull request: https://github.com/jquery/jquery/pull/181. Let me know what do you think.
Changed January 17, 2011 11:43PM UTC by comment:3
component: | unfiled → ajax |
---|---|
priority: | undecided → blocker |
status: | new → open |
Changed January 25, 2011 01:47AM UTC by comment:4
milestone: | 1.next → 1.6 |
---|
Just moving this to 1.6 so we can consider the patch.
Changed February 01, 2011 11:34PM UTC by comment:5
_comment0: | Fixes #7945. Make jQuery.param() serialize plain objects with a property named jquery correctly. \ Changeset: fdd4101fe93321f33b916a92b5def1328ea331b3 → 1296603458500466 |
---|---|
resolution: | → fixed |
status: | open → closed |
Fixes #7945. Make jQuery.param() serialize plain objects with a property named jquery correctly.
Changeset: fdd4101fe93321f33b916a92b5def1328ea331b3
https://github.com/jquery/jquery/commit/fdd4101fe93321f33b916a92b5def1328ea331b3
Changed February 01, 2011 11:39PM UTC by comment:6
milestone: | 1.6 → 1.5.1 |
---|---|
priority: | blocker → high |
version: | 1.4.4 → 1.5 |
For context, Anton is the lead js dev at Disqus.