Form form submission data problem

巴扎黑
Release: 2016-12-19 14:26:38
Original
1542 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 ‐ ‐ ‐ var str=this. ‐ ‐ ‐ ‐ var str=this. 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] Only then will enter er SerializeObj [this.Name] .push (this.value);
}} else {
if (this.value) {// The second option is worth it. null, undefinded ] will enter
serializeObj serializeObj serializeObj
}); 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!