ROOMS-149: Refactor redirect logic for both AJAX and non-AJAX.