#7945 closed bug (fixed)
jQuery.param thinks that { jquery: "1.4.2" } is a jQuery object
Reported by: | 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
Change History (6)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
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.
comment:3 Changed 13 years ago by
Component: | unfiled → ajax |
---|---|
Priority: | undecided → blocker |
Status: | new → open |
comment:4 Changed 13 years ago by
Milestone: | 1.next → 1.6 |
---|
Just moving this to 1.6 so we can consider the patch.
comment:5 Changed 13 years ago by
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
comment:6 Changed 13 years ago by
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.