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); }                    }                });



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

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.