js a form of key-value sequence of the form

// define a utility method for the specified form in the form of all data entries into json {key: value, key: value}

$.fn.serializeJson=function(){  
    var serializeObj={};  
    var array=this.serializeArray();
    $(array).each(function(){  
        if(serializeObj[this.name]){  
            if($.isArray(serializeObj[this.name])){  
                serializeObj[this.name].push(this.value);  
            }else{  
                serializeObj[this.name]=[serializeObj[this.name],this.value];  
            }  
        } The else {   
            serializeObj [ the this .name] = the this .Value;    
        }   
    });   
    return serializeObj;   
}; 

$ ( . "#Btn") the Click ( function () {
     // the specified form in the form of all entries turn Key to json data {: value, Key: value} 
    var P = $ ( "# searchForm" ) .serializeJson (); 
    console.info (P); 
    // call the load method table data, sent once again ajax request, and submit parameter 
    $ ( "# Grid") the DataGrid ( "the Load." , the p-);
     // close the query window 
    $ ( "# searchWindow") window ( "use Close." ); 
});

 

Guess you like

Origin www.cnblogs.com/lazyli/p/10965570.html