A $.ajax({
type: "POST",
url: reqUrl,
data: reqBody,
dataType: "json",
success: function(data, textStatus) {
if (data.redirect) { // data.redirect contains the string URL to redirect to window.location.href = data.redirect;
} else { // data.form contains the HTML for the replacement form $("#myform").replaceWith(data.form);
}
}
});
B public ActionResult Index(){
if (!HttpContext.User.Identity.IsAuthenticated) { HttpContext.Response.AddHeader("REQUIRES_AUTH","1");
}
return View() }
C $.ajax( error: function (jqXHR, timeout, message) {
var contentType = jqXHR.getResponseHeader("Content-Type");
if (jqXHR.status === 200 && contentType.toLowerCase().indexOf("text/html") >= 0) { window.location.reload();
}
});
D $(document).ready(function () {
$(document).ajaxSend( function(event,request,settings) {
var intercepted_success = settings.success;
settings.success = function( a, b, c ) {
if( request.responseText.indexOf( "<html>" ) > -1 )
window.location = window.location; else intercepted_success( a, b, c );
};
});
});