fix bug when ajax request was redirected