you will never, ever code calls to XHR. Instead you will use a library. The library will either be embedded accessible from a UI component library such as isomorphic, Active Widget or will be a wrapper library such as Prototype as Ben Souther said.
HTH.