You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

32 line
783 B

  1. /*!
  2. * jQuery serializeObject - v0.2 - 1/20/2010
  3. * http://benalman.com/projects/jquery-misc-plugins/
  4. *
  5. * Copyright (c) 2010 "Cowboy" Ben Alman
  6. * Dual licensed under the MIT and GPL licenses.
  7. * http://benalman.com/about/license/
  8. */
  9. // Whereas .serializeArray() serializes a form into an array, .serializeObject()
  10. // serializes a form into an (arguably more useful) object.
  11. (function($,undefined){
  12. '$:nomunge'; // Used by YUI compressor.
  13. $.fn.serializeObject = function(){
  14. var obj = {};
  15. $.each( this.serializeArray(), function(i,o){
  16. var n = o.name,
  17. v = o.value;
  18. obj[n] = obj[n] === undefined ? v
  19. : $.isArray( obj[n] ) ? obj[n].concat( v )
  20. : [ obj[n], v ];
  21. });
  22. return obj;
  23. };
  24. })(jQuery);