Ajax passes an array to the background. NET MVC Controller

Source: Internet
Author: User

The array structure is: ["5ae92c2786f3591b2cff1be5", "5ae91bb7ca673569a8d23a6e"]

Front Code:

$.ajax ({type:"POST", URL:"/registration/managementproject/deleteprojectbyid", DataType:"JSON", data: {"Selectdata": that. Useridarray}, Async:false, Traditional:true,//set to True hereSuccessfunction(data) {that.projectlist=data; Console.log (data)if(Data. Response.errcode = = "0") {alert (data.                            RESPONSE.ERRMSG); //Empty the selected datathat. Useridarray = []; Applist.gatprojectlist (1); }                    }                });

Attention:

Attention:

1, that. Useridarray is an array

2. The data in the Ajax parameter is {"Selectdata": that. Useridarray}

3, this way is more important is traditional:true. or convert the _list parameter to $.param (_list.true). Here is actually the _list as a traditional way to pass to the background, jquery is the default is to do the conversion

Background code

// /<summary>       // /Delete Items       based on selected ID // /</summary>       // /<param name= "Selectdata" > selected array of items  can also be list<string></param>       // /<returns></returns> Public         Iactionresult Deleteprojectbyid (string [] selectdata)        {        

Ajax passes an array to the background. NET MVC Controller

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.