Sending cross domain AJAX requests is a bothering problem for newbie AJAX developers. If your application is running in http://domain1, sending a request to http://domain2 is a security issue and the browser doesn’t allow it.
A JSONP(JSONP for Padding) request solves this problem with the server returning a JSON response padded with a key. For example if the server sends {“message”:”hello”} as usual response, in JSONP the response is send as key({“message”:”hello”}) where the key is a callback function that the response-receiving client needs to have.
Another way to solve this is CORS(Cross Origin Resource Sharing), a HTML 5 feature. The server application needs to send a HTTP header called “Access-Control-Allow-Origin” (ACAP) which defines a permission. For instance, if domain1 were to send a request to domain2, then domain2 needs to send a HTTP header ACAP with the value “http://domain1” that indicates the permission. RESTful services like open weather map or yahoo stock quotes have ACAP header value set to “*” that makes them accessible from any application.
You can read more about CORS here.