move js into ajax success callback