fix a bug & add ajax redirect support