, , , AJAX : Yahoo, , , , script, . .
, , alert, , , , .
AJAX ( "AJAX" " Javascript XML" , XmlHttpRequest):
var url = "http://query.yahooapis.com/v1/public /yql?"+"q=select%20*%20from%20html%20where%20url%3D%22"+encodeURIComponent(url)+"%22&format=xml'&callback=?";
$.getJSON(url, function(data) { ... });
$.ajax({
type: 'GET',
url: url,
dataType: 'json',
data: {},
async: false,
success: function(data) { ... },
});
( ) , .
, , , , :
while (...) {
function myFunction() {
var x = document.getElementById("prova").textContent;
alert(x);
}
fetch_and_handle(website_url, myFunction);
}
function fetch_and_handle(url, handler) {
var container = $('#prova');
var url = "http://query.yahooapis.com/v1/public /yql?"+"q=select%20*%20from%20html%20where%20url%3D%22"+encodeURIComponent(url)+"%22&format=xml'&callback=?";
$.getJSON(url, function(data) {
if (data.results[0]) {
var data = filterData(data.results[0]);
container.html(data);
if (handler != undefined) {
handler();
}
}
else {
var errormsg = '<p>Error: could not load the page.</p>';
container.html(errormsg);
}
}
}
var : , var. .