Fix ajax requests and convert prototype code