Better abstraction for XMLHttpRequest