Ticket #3523 (closed enhancement: wontfix)
serialize() and serializeArray() to include submit button when only one in form
| Reported by: | kswedberg | Owned by: | john |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.3 |
| Component: | ajax | Version: | 1.2.6 |
| Keywords: | serialize,submit,ajaxrewrite | Cc: | |
| Blocking: | Blocked by: |
Description
Per John Resig's request ( http://groups.google.com/group/jquery-dev/browse_thread/thread/f82bccd7bebdc838), I'm submitting this ticket to include the submit button in the serialize() string / serializeArray() object when there is only one submit button in the form, even though, as he mentioned, "we may not get to it."
I'm sure it can be improved quite a bit, but here is one way to achieve this:
change line 74 of ajax.js from this:
/text|hidden|password/i.test(this.type));
to this:
/text|hidden|password/i.test(this.type)) $(this).filter(":submit").length == 1 && /submit/i.test(this.type);
Change History
comment:3 Changed 5 years ago by flesler
- need changed from Review to Patch
- Owner set to john
You need to wrap them with:
{ { { code... } } }
comment:4 Changed 3 years ago by dmethvin
- Status changed from new to open
I'd prefer to see a way to specify the button that was pressed, which would work for cases where there are multiple buttons as well.
comment:5 Changed 2 years ago by rwaldron
- Keywords serialize,submit,ajaxrewrite added; serialize, submit removed
comment:7 Changed 2 years ago by john
- Status changed from open to closed
- Resolution set to wontfix
Yeah, I don't think that is something that we're going to change - this is precisely why the jQuery Ajax Form plugin exists: http://jquery.malsup.com/form/
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

well, that didn't work the way I had intended. Here is the "change to" code again:
/text|hidden|password/i.test(this.type)) || $(this).filter(":submit").length == 1 && /submit/i.test(this.type);