On the Server side response with similar code:
header('HTTP/1.0 278 Ok');
echo json_encode(array('redirect' => "/"));
exit;
In JQuery bind AjaxSuccess to this function. Somewhere in a global header or layout page, so it get accesses from all pages.
$('body').bind('ajaxSuccess',function(event, request, settings){
if (request.status == 278){
jsonresponse = $.parseJSON(request.responseText);
$('form').dirtyForms('setClean');
window.location.href = jsonresponse.redirect;
}
});
This entry was posted in PHP. Bookmark the permalink.