Application Cases of JSON in web interaction

Source: Internet
Author: User
Tags form post

When it comes to JSON, everyone will think of a data structure like this:

Yes, JSON does bring us beautiful data. This is convenient for us.

In normal times, we often encounter data information such as list <model>. Such as list <student> and list <studentsetting>. However, we do not want to use serializaarray () when using form post, because it is difficult for us to determine whether data has specific front-end business impact on the front-end. For example, when Zhang San is clicked, he is the shift leader. In his setting, there will be an additional permission control or management score evaluation. Therefore, we cannot simply use serializaarray to submit his value, because his score has to be evaluated by referring to the performance score of other students (more), I believe that people here know that serializaarray may not be able to meet the requirements (for example, younger brother blind ). It is important that if serializaarray is used, the backend will be extremely bulky to accept data. What should I do?

This wayCodeWhich is quite annoying. Although IDS, names... They all correspond to each other in the correct sequence. That's right. This is my intuitive idea. Because you cannot tell what operations are available on the page! For example, if you do not select the checkbox option, does the next checkbox value go to the previous index ?), Well, you can use the value to do your hands and feet, and implant ID stitching for background differentiation. But the problem arises again. How can we change the shadow even if the list is received. Don't you think the code is too heavy?

 

At this time, I thought of JSON. Decode. That's right! Is system. Web. helpers. JSON. Decode.

What about the front-end when it comes to backend solutions?

The open-source world is like a bright pearl! The footprints of giants are enough for the younger brother to learn. Douglascro ckford has created conditions for us: https://github.com/douglascrockford/json-js. I have the opportunity to study things in it.

 

VaR Params = {

"Setdata": jsondata

};

For example, the actual data is much more complex than this. For example, each TR, find ("[]"). Val () and other processing methods are included.

 

In the interaction stage, the backend is easy to do:

Is it easy? Do you think the code is lighter than that. The important scalability is enhanced. When some new fields and new page data appear, we only need to gently change the student object structure.

 

For the first time, I wrote such an article. I am sorry for the poor writing and I am sorry to point out criticism.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.