This example demonstrates how to use the Connection Manager and a PHP proxy — to work around XMLHttpRequest's same-domain policy — to retrieve an XML document from
To try out the example, fill in your five-digit US zip code, or Location ID.
Yahoo! Weather RSS will return an XML document if the transaction is successful. The following callback object with
failure handlers is used to process the response.
The Yahoo! Weather RSS feed requires a simple HTTP GET request with a base URL and a querystring containing the required information as a name-value pair. In this example, we will use the following parameter:
p— location as U.S. Zip Code or Location ID
The following are some example location IDs (do not include the city name):
For more details on the Yahoo! Weather RSS feed and other location IDs, please visit http://developer.yahoo.com/weather/index.html.
getModule retrieves the input values for location and creates a querystring:
weather.php receives the querystring, it will construct and send an HTTP GET using CURL to retrieve the results from the Yahoo! Weather RSS feed. This allows the transaction to succeed while working around XMLHttpRequest's strict security policy.
Note: Logging and debugging is currently turned off for this example.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.