I have the following JS:
$('form').live('submit', function (event) {
// Stop the form from doing a native postback
event.preventDefault();
$.ajax({
type: 'POST',
timeout: 5000,
url: $(this).attr('action'),
data: $('form').serialize(),
success: function (responseHtml) {
$.getJSON($(this).attr('action'), function (data) {
console.log(data);
});
},
error: function (jqXHR, textStatus, errorThrown) {
alert('server error');
}
});
});
Which should log the json from the following mvc method on fail (note this is a login fail and not the ajax error!):
[HttpPost]
public JsonResult Login(User user, string returnUrl)
{
// Validate the email and password
if (users.Login(user.UserName, user.Password, Request.UserHostAddress))
{
FormsAuthentication.SetAuthCookie(user.UserName, true);
// build redirectUrl ...
//var redirUrl = ...
return Json(new { uservalidated = true, url = false });
}
else
{
return Json (new { uservalidated = false, url = false });
}
}
If I disable the JS then I see the result fine but for some reason the JS can't see it :/
returnUrl?