A security feature of all browsers prevents you from making XMLHttpRequests to other domains. This is called the Same Origin Policy. There are a few ways to get around the same origin policy,
1. Provide a proxy to the service using a server-side language.
Normally, you would make requests directly to a web service, which would in turn return a response, like so:
╒═══════════════════╕ ──────────────> ╒═══════════════════╕
│ Client/Javascript │ │ Server/WebService │
╘═══════════════════╛ <────────────── ╘═══════════════════╛
Proxying involves writing a server-side script to act as a middle-man:
╒═══════════════════╕ ────> ╒════════════════════╕ ────> ╒═══════════════════╕
│ Client/Javascript │ │ Same domain server │ │ Server/WebService |
╘═══════════════════╛ <──── ╘════════════════════╛ <──── ╘═══════════════════╛
So the browser is making a request to the same domain, it isn't blocked by the same-origin policy. The server in turn makes the request to the remote web service, which returns the response. Finally, the same domain server returns that response to the script, which is still waiting. This works because requests made by the server aren't subject to the same-origin policy.
2. Check to see if the service offers a JSONP data format.
JSONP works by adding a script element to the current page, with the src attribute pointing to the web service. The web service returns the response in the form of a JavaScript function call with the data in a JavaScript object literal that is passed as the argument to the function. All you need to do is predefine that function so that when the script/webservice request completes your predefined function is called with the data so that you can handle it.