Add support for CORS / XHR

Not ready for merging yet as there are no tests, but all is working and more importantly the existing tests are passing.
Be careful using JSON. Does IE have it? Check if browser has JSON and fallback otherwise.

Validate responseText before calling JSON.parse
Also try/catch JSON.parse in case response is invalid.