0
< 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>
Man 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 shown in the image, and I wanted the return to success
of jquery
.
Does anyone have any idea how I return the value true
or false
in the success
jQuery to display a alert
of the return?
Possible duplicity: http://answall.com/questions/29382/fun%C3%A7%C3%A3o-ajax-return-value
– Maurivan
I think the right thing would be something like:
success: function(data) {
 if (data.ret == true) {
– Guilherme Nascimento