Updated javascript for Ajax