Hello developers, I am trying to save data in my database using ajax, but at the moment of running my app it seems to omit the portion of the code that would allow me to save the data, this is the code I am using.
<script>
$(".clMotivo").click(function (event) {
var id = $(this).attr("data-id");
var data = $(this).serialize();
var gafete = $("txtGafete").val();
var datos = {};
datos = {
motivo_Id: id,
gafete: gafete
};
$.ajax({
url: "http://localhost:49851/api/visita/agregar",
method: "POST",
data: JSON.stringify(datos),
contentType: "aplication/json",
success: function (data) {
alert(data);
ocultarPopUpAcceso();
}
});
});
</script>
will be that I lack something in this same code or it will be that I must serialize the json in the controller did not take much programming in mvc and that's why I have that doubt I hope you can understand my point and help me a little