I am using the jquery ajax plugin to submit a form.
$('#profile-form').ajaxForm({
success:function(response, statusText, xhr, $form){
console.log(statusText,response,xhr);
},
beforeSubmit : function(formData, jqForm, options){
if ($('#permissions').data("permissionsModified") == true){
formData.push({name : 'selectedPermissions', value : JSON.stringify($('#permissions').data('selected'))});
}
}
});
The server sends a redirect request back and the following is displayed on the firebug console :
302 Moved Temporarily
in front of the action url of the form.
Immediately after that, the redirect URL is shown and the ‘request in progress’ symbol in from of that keeps rotating. In the success callback of ajaxform, the statusText is “success” and the response text is the entire new redirect page. How to check whether the server has redirected the requested (and then, how the display the redirected page on the browser) or there was a json reposnse from the server
If I remember rightly, the browser should silently (transparently) follow any redirects issued over an AJAX request.
After a little digging, it appears I am correct, see point 2: http://www.w3.org/TR/XMLHttpRequest/#same-origin-request-event-rules
The only solution I can think of is a custom status code, but that’s kind of stretching the paradigm a bit far. Unfortunately not much else can be done.