Created
          August 20, 2012 21:47 
        
      - 
      
 - 
        
Save elijahmanor/3408190 to your computer and use it in GitHub Desktop.  
    Serialize Form Into Object
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | //Uses jQuery's serialize form method & then transforms data into an object | |
| var data = {}; | |
| $.each( $( "#Form" ).serialize().split( "&" ), function( index, item ) { | |
| var keyValue = item.split( "=" ); | |
| data[ keyValue[ 0 ] ] = decodeURIComponent( keyValue[ 1 ] ).replace( /\+/g, " " ); | |
| }); | |
| console.log( JSON.stringify( data, null, 4 ) ); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment