@*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 SinghPosted Oct 5, 2020, 9:34 PM
Schleid AlexPosted Oct 5, 2020, 6:29 PM
Mageshwaran RPosted Oct 5, 2020, 11:16 AM
Asma KhalidPosted Oct 2, 2020, 2:10 AM
Sachin SinghPosted Oct 1, 2020, 11:20 PM