Bug Tracker

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#7945 closed bug (fixed)

jQuery.param thinks that { jquery: "1.4.2" } is a jQuery object

Reported by: anton@… Owned by:
Priority: high Milestone: 1.5.1
Component: ajax Version: 1.5
Keywords: Cc:
Blocked by: Blocking:


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.


Change History (6)

comment:1 Changed 5 years ago by paul.irish

For context, Anton is the lead js dev at Disqus.

comment:2 Changed 5 years ago by anton@…

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 5 years ago by rwaldron

  • Component changed from unfiled to ajax
  • Priority changed from undecided to blocker
  • Status changed from new to open

comment:4 Changed 5 years ago by dmethvin

  • Milestone changed from 1.next to 1.6

Just moving this to 1.6 so we can consider the patch.

comment:5 Changed 5 years ago by Anton Kovalyov

  • Resolution set to fixed
  • Status changed from open to closed

Fixes #7945. Make jQuery.param() serialize plain objects with a property named jquery correctly.

Changeset: fdd4101fe93321f33b916a92b5def1328ea331b3


Last edited 5 years ago by paul.irish (previous) (diff)

comment:6 Changed 5 years ago by jitter

  • Milestone changed from 1.6 to 1.5.1
  • Priority changed from blocker to high
  • Version changed from 1.4.4 to 1.5
Note: See TracTickets for help on using tickets.