Correctly reload or redirect upon Ajax requests (see #5647)