jquery / jquery/jquery-migrate
Migrate error from within jQuery when using $.serialize with $.ajaxSettings.traditional
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.1k
- Forks
- 476
- Avg merge
- 10m
- Merged PRs (30d)
- 1
Description
My site uses $.ajaxSettings.traditional = true, and we're working on upgrading to jQuery 3 now. The migrate script is showing a warning when I use $('form').serialize() because the implementation within jQuery uses param without checking the value of the traditional flag.
jQuery.fn.extend( {
serialize: function() {
return jQuery.param( this.serializeArray() );
},
...
})
(from serialize.js line 99-ish)
I was able to fix the warning by replacing $('form').serialize() with $.param( $('form').serializeArray() , $.ajaxSettings.traditional ), but I'm wondering for future users if it wouldn't be helpful to either:
- Update the migrate documentation to suggest this fix (other programmers might have a hard time understanding what the problem is, since the migrate documentation doesn't reference
serializeanywhere; I was confused for a bit before I realized that the offending code was within jQuery), or - modify the jQuery source to explicitly use the
traditionalflag in theserializeimplementation:jQuery.fn.extend( { serialize: function() { return jQuery.param( this.serializeArray(), jQuery.ajaxSettings.traditional ); }, ... })
Happy to PR if either of those is desirable.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the migration warning in warnings.md and the serialize implementation in src/serialize.js, then compare how $.param handles the traditional flag. Determine whether the accepted resolution is documentation or a jQuery behavior change; done means the chosen path clearly addresses serialize users and is supported by the relevant project checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, tooling
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100