i have this list of hidden fields
<input type="hidden" value="1" id="serviceslist" name="serviceslist" />
<input type="hidden" value="2" id="serviceslist" name="serviceslist" />
<input type="hidden" value="3" id="serviceslist" name="serviceslist" />
i have add more button which when clicked want to sent the serviceslist to mvc controller. basically i think that i need to send the list as array. how can i do it?
$('#addmoreservices').click(function () {
var serviceslist= $("#serviceslist").val()
$.ajax({
url: url,
data: { serviceslist: serviceslist },
cache: false,
dataType: "json",
traditional: true,
type: "POST",
success: function (data) {
alert("dddd");
},
error: function (reponse) {
alert("error : " + reponse);
}
});
});
this is my mvc controller
[HttpPost]
public ActionResult AddmoreServices(List<int> serviceslist)
{
return View();
}
idshould be unique