That is slightly different, but should work the same:
$(document).ready(function() {
$('#top_section_notice input[type=submit]').click(function() {
var $form = $(this).closest('form'),
data = {};
$form.submit(function() {
$(this).find('input,select').each(function (index, value) {
var $val = $(value);
data[$val.attr('name')] = $val.val();
});
$.ajax({
type: 'POST',
url: $form.attr('action'),
data: data,
beforeSend: ajax_indicator(true)
})
.done(function(request) {
var $req = $(request);
if ($req.find('#frmLogin').length > 0)
{
document.open();
document.write(request);
document.close();
history.pushState(null, $req.attr('title'), $form.attr('action'));
}
else
location.reload(true);
})
.fail(function() {
window.location.href = $form.attr('action');
})
.always(function() {
ajax_indicator(false);
});
return false;
});
});
});
Adding it to... for example script_elk.js, the login should become "AJAX" and if successful the page will just reload without being redirected to "wrong" pages.
It's a bit tricky, but I guess it's allowed.