Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. /**
  2. * serializeObject - jQuery plugin to serialize form elements as an object
  3. * @uses $("#form").serializeObject(); // return {input:"value", input2:"value" .. }
  4. */
  5.  
  6. $.fn.serializeObject = function(){
  7. var o = {};
  8. var a = this.serializeArray();
  9. $.each(a, function() {
  10. if (o[this.name] !== undefined) {
  11. if (!o[this.name].push) {
  12. o[this.name] = [o[this.name]];
  13. }
  14. o[this.name].push(this.value || '');
  15. } else {
  16. o[this.name] = this.value || '';
  17. }
  18. });
  19. return o;
  20. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement