Fix ajax method undefined variable