Schleid Alex

Schleid Alex

  • 1.7k
  • 291
  • 7.3k

Posting form data using jquery ajax with html

Oct 1 2020 1:50 PM
I have a view with 4 element ID Name Location I want to submit this form using jquery. The form id is "divData"
 
Here is my jquery save function
 
function SaveChanges()
{
alert("Do you want to save the changes?")
var token = $('input[name="__RequestVerificationToken"]').val();
var urlCreateDev = $('#urlCreateDev').val()debugger;
$.ajax(
{
url: urlCreateDev, // this contain the url //
type: 'Post',
contentType: 'apllication/html;
charset-utf-8',data:
{
divData, token
},
datatype: 'html',
success: function (result)
{
$('#DivInfoData').modal('hide')},
error: function (xhr, status, error)
{
alert(xhr.responseText);alert(xhr.status);alert(error);
}
}
)
}
 
This will not work...
 
One more thing. My controller will return true when data is successfully posted to the database and false when not, I would like to be able to evaluate the return data from my controller in order to hide or keep the modal form
 
Thank you! Any help will be greatly appreciated.
 
Regards

Brought to you by:

Answers (4)