moved ajax into JS