Ajax passing arrays to the background

Source: Internet
Author: User

// entity class class person{   privateint id{get;  Set;}      Private string name{get;  Set;}    Private int age{get;  Set;}}

//Front desk JS code
vararray=NewArray (); for(inti=0;i<5;i++){ varoption={}; Option.id=1; Option. Name= "Test"; Option. Age=21; Array.push (option); //add data to an array}$.ajax ({URL:"Index/saveperson",//the path to receive data in the backgrounddata:{"Person": Json.stringify (Array)},//Pass ValueType: ' Post ', DataType:' JSON ', success:successed//return function After successful background execution});functionsuccessed () {alert ("It ' s ok!") }

 Public string Saveperson (string person ) {  // introduction of serialization  new  JavaScriptSerializer ();   // Serialization of   var list = serializer. deserialize<list<person>>(person);     //   The back is not written to this list is a collection of the back you don't need me to say it }

Ajax passing 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.