Bug Tracker

Opened 11 years ago

Closed 9 years ago

#3463 closed enhancement (invalid)

serialize functions only for forms?

Reported by: greggreenhaw Owned by:
Priority: major Milestone: 1.3
Component: ajax Version: 1.2.6
Keywords: form, ajax, serialize Cc:
Blocked by: Blocking:

Description

Why do the serialize functions only work on forms? People are moving away from forms. They are not needed with ajax. Why put useless restrictions on jquery. Here are some quick fixes or alternative for people to use. I understand it is easy to loop throught the elements array of a form.

jQuery.fn._serializeArray=function() {

return this.map(

function() {

var name=$(this).attr('name'); var type=$(this).attr('type'); var val=$(this).val(); var checked=$(this).attr('checked'); if(type=='checkbox' && !checked)

return;

return {name:name,value:val}; } );

};

jQuery.fn._serialize=function() {

return this.map(

function() {

var name=$(this).attr('name'); var type=$(this).attr('type'); var val=$(this).val(); var checked=$(this).attr('checked'); if(type=='checkbox' && !checked)

return;

return escape(name)+'='+escape(val); } ).get().join('&');

};

Change History (1)

comment:1 Changed 9 years ago by Rick Waldron

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.