moved ajax calls out into api.js