Home > Java > javaTutorial > Form form submission data problem

Form form submission data problem

巴扎黑
Release: 2016-12-10 09:19:10
Original
1198 people have browsed it

Submitting data through form forms is not difficult at all, but it can become difficult if you don’t handle it well!
A method that has been encapsulated by javascript is serialize(), but this method is to load the form data into key1=value1&key2=value2&... Everyone knows that this format is not Json format, and the data in this format is passed to the background JSONObject .parseObject() cannot be parsed! ! !
So in order to conveniently use JSONObject to convert the data from the front desk into java objects, the author prefers to use the following method:


$.fn.serializeJson=function(){
        var serializeObj={};
    var array= this.serializeArray();
    var str=this.serialize();
                                                                                                                                                              using using using   using using         using using ‐ ‐ ‐ ‐ var str=this.serialize();            Multi -choice f IF ($. Isarray (Serializeobj [this.Name])) {
if (this.value) {// The options of the second one after the check box are valuable [except empty string, null, undefinded] will enter
                      serializeObj[this.name] ​             if(this.value){ // The second option of the check box has a value [Except empty string, null, undefinded] will enter
SerializeObj [This.name] = [SerializeObj [This.name], this.value]; = this.value;
}
}); t Return Serializeobj;
};


This is to serialize the form form data into JSON objects, and then use json.stringify () to transparent json objects into json fonts to the background!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template