@*Modal form Create*@
That I use to display a partial view code below
@*
EnrolledDevicesModel
*@
And I use jquery ajax to post data whenever the save change button is clicked script below
function SaveChanges() {
$('#btnCreateDv').click()
var token = $('input[name="__RequestVerificationToken"]').val();
var urlCreateDev = $('#urlCreateDev').val()
var frm = $('#dvCreateFrm').serialize();
$.ajax({
url: '/EnrolledDevices/Create' /*'@Url.Action("Create","EnrolledDevices")'*/ /**/,
type: 'Post',
contentType: 'apllication/html; charset-utf-8',
data: { frm, token },
datatype: 'html',
success: function (response) {
$('#DivCreateEnrolledDevices').modal('hide')
},
error: function (xhr, status, error) {
alert(xhr.responseText);
alert(xhr.status);
alert(error);
}
})
}
and my controller code is like
public ActionResult Create(FormCollection collection)
{
LoadFormData( collection);
try
{
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
but for some reason no data is being sent to the controller.
I just can't figure out what I have done wrong
Can I get some help here
Thanks in advance
Schleid

Sachin SinghRank #66 · 26.2K reputationPosted Oct 1, 2020, 7:20 PM EDT
Asma KhalidRank #160 · 14.7K reputationPosted Oct 1, 2020, 10:10 PM EDT
Mageshwaran RRank #411 · 6.1K reputationPosted Oct 5, 2020, 7:16 AM EDT
Schleid AlexRank #3,087 · 464 reputationPosted Oct 5, 2020, 2:29 PM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Oct 5, 2020, 5:34 PM EDT