Fixed ajax redirect problem. Closes #886