restructure how app.js does ajax calls