Moved ajax request to app.js file

cleaning up the javascript