Remember the previous just wrote the value of ASP. NET from the front desk is var data=a,b,c,d,e; Loop to add a comma separated from the background also to be tested only input, it is wrong haha. Later, using a similar symbol is not a permanent ...
Now with the MVC, form add, on each input to write the corresponding model of the name, to the background directly model point properties on the line.
However, you will still encounter the submission is not a form, similar to submit exam answers, after-class evaluation, a large string of strings. See JS object in front of a bright!!! On the Code
Html:
<ul>
<li class= ' id ' >1</li>
<li class= ' name ' >A</li>
</ul>
<ul>
<li class= ' id ' >2</li>
<li class= ' name ' >B</li>
</ul>
--------------------------------------------------------------------------------
I would have written 1,a.2,b to the backstage if I had changed it. It's not the same now.
var orgarray={};//first declares a global array
$ (UL). each (function () {
var organ={
id=$ (This). Children (Li:eq (0)). HTML (),
name=$ (This). Children (Li:eq (1)). HTML ()
}
Orgarray.push (Organ); Equals List Collection
})
$.post ("url", {orgarray: json.stringify(orgarray)//Convert to String}, function (data) {})
If you pass a lot of string level, you can also set a few more Var arry={};
----------------------------------------------------------------------------------------------
Background
var Orgarray = request.form["Orgarray"];
Dynamic Orglist = Newtonsoft.Json.JsonConvert.DeserializeObject(Orgarray);
for (int i = 0; i < Orglist.count; i++)
{
Id=orglist[i].id;
Name=orglist[i].name;
Add to
}
-------------------------------------------------------------------------------------------
In this way with the previous comma stitching comparison, personally think 1: conducive to future maintenance! Directly know the meaning of the property, the province in the front desk to check, concise, convenient. 2: Avoid separating with special symbols, some errors occur. 3: Conforms to C # object-oriented