Cleaning up XHR interactions into a separate file in preparation for synchronous XHR.