Jquery Ajax transmits the array parameter value to the server, jqueryajax
When using MVC, when sending a POST request to the server, you sometimes need to pass an array as the parameter value.
The following is an example. First, let's take a look at the Action.
[HttpPost]public ActionResult Test(List<string> model){ return Json(null, JsonRequestBehavior.AllowGet);}
Method 1: Construct the form element and call the serialize () method to obtain the constructor string.
@ {Layout = null ;}<! DOCTYPE html>
Debug mode monitoring parameters. When you click the button, the monitoring parameters are as follows:
Method 2: Use a JavaScript Object as a parameter to pass the value. The parameter name is the parameter name corresponding to the Action method, and the parameter value is a JavaScript array.
@ {Layout = null ;}<! DOCTYPE html>
Method 3: Use Json as the parameter request. In this case, Ajax needs to declare Content-Type as application/json
@ {Layout = null ;}<! DOCTYPE html>
The above example uses ASP. net mvc 5