jquery Ajax passes multiple objects or arrays to the background

Source: Internet
Author: User

1, JS object creation: Because the object JSON needs to be serialized, can be passed to the background, the background based on the JSON string deserialization.

2, the Jquery $.ajax method configuration

The configuration parameters for the $.ajax method need to be modified:

1) DataType: "JSON", Traditional:true: The data type must be JSON. By default, traditional is false, which means that jquery will serialize the parameter object in depth.
But Servelt API cannot handle, we can prevent deep serialization by setting traditional to True

2) This is the point! The JS object needs to be JSON serialized, otherwise it cannot be delivered to the server.

Json.stringify (Textdatainfo)

3, the server side to deserialize:

list<study> list = newtonsoft.json.jsonconvert.deserializeobject<list<study>> (TextDataInfo);

Newtonsoft.Json.JsonConvert is a free Json conversion tool from Microsoft.

Reference the Newtonsoft.Json.dll file in the application.

This allows you to switch directly to the entity in the background.

Front desk:

Background:

You can see the effect:

jquery Ajax passes multiple objects or arrays to the background

Related Article

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.