I have actionresult as below
[HttpPost]
public ActionResult AddRoomFeature(string[] selectedFeatures, int RoomID)
{
return View();
}
Javascript Ajax
var selectedFeatures = [];
$('input.Hotelfeature:checkbox:checked').each(function () {
selectedFeatures.push($(this).val());
});
$.ajax({
type: 'POST',
url: '@Url.Action("AddRoomFeature", "HotelRoom")',
data: {
selectedFeatures: JSON.stringify(selectedFeatures),
RoomID: $("#RoomID").val()
},
success: function (data) {
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("error");
}
});
Question:
If i post selectedFeatures to actionresult,
selectedFeatures displays value as ["\1",\"2\"]
Normally value should display as "1","2" in string array.
Where i miss in ajax code ?
Any help will be appreciated.
Thanks.