Request.YQLajax = new Class({
// gets basic info such as country and latitude data
Extends: Request.JSONP,
options: {
log: !true,
url: "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22{location}%22&format=xml"
},
initialize: function(location, options) {
this.parent(options);
if (!location)
return;
this.options.url = this.options.url.substitute({location: encodeURIComponent(location)});
},
success: function(data, script) {
this.parent(data, script);
}
});
$("fetch").addEvents({
click: function() {
new Request.YQLajax("http://www.bbc.co.uk/", {
onSuccess: function(data) {
$("result").set("html", data.results);
}
}).send();
}
});
<div id="result"></div>
<div id="fetch">click to fetch from bbc.co.uk</div>
#fetch {
border: 1px solid #000;
cursor: pointer;
_cursor: hand;
}