clean up use of promises in ajax.js a bit