< script type = "text/javascript" >
$(document).ready(function() {
$('#btnEnviarDados').click(function() {
var strFomr = $("form").serialize();
$.ajax({
url: $("form").submit(),
type: "POST",
data: strFomr,
contentType: 'application/json; charset=utf-8',
cache: false,
success: function(ret) {
if (ret == true) {
alert('funcionaou');
location.href = "@Url.Action("
Contact ")"
} else
alert("noa funcionou a rquisicao");
}
});
});
}) < /script>
My Controller :
public JsonResult CadastroUsuario(Usuario _usuario )
{
if (ModelState.IsValid)
{
return Json(new{ret = true });
}
else
{
return Json(new { ret = true });
}
}
The problem is that in View returns only the value true
or false
as the image shows, and I wanted the return to be success
of jquery
.
Does anyone have any idea how to return the value true
or false
in success
of jQuery to display a alert
of the return?