nie za bardzo rozumiem jak działa ta metoda .
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta http-equiv='cache-control' content='no-cache'>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<div id="loading"><img src="images/loading.gif" width="20" height="20" border="0"></div>
<div id="content"> </div>
<script type="text/javascript" src="script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" >
// Accepts a url and a callback function to run.
function requestCrossDomain( site, callback ) {
// If no url was passed, exit.
if ( !site ) {
alert('No site was passed.');
return false;
}
// Take the provided url, and add it to a YQL query. Make sure you encode it!
var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from html where url="' + site + '"') + '&format=xml&callback=?';
// Request that YSQL string, and run a callback function.
// Pass a defined function to prevent cache-busting.
$.getJSON( yql, cbFunc );
function cbFunc(data) {
// If we have something to work with...
if ( data.results[0] ) {
// Strip out all script tags, for security reasons.
// BE VERY CAREFUL. This helps, but we should do more.
data = data.results[0].replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '');
// If the user passed a callback, and it
// is a function, call it, and send through the data var.
if ( typeof callback === 'function') {
callback(data);
}
}
// Else, Maybe we requested a site that doesn't exist, and nothing returned.
else throw new Error('Nothing returned from getJSON.');
}
}
requestCrossDomain('http://xxx.pl/gadzet/content.php', function(results) {
$('#kontener').html(results);
});
</script>
<div id="kontener"></div>
</body>
</html>
Jaką rolę odgrywa url
http://query.yahooapis.com/v1/public/yql?q w tym skrypcie ? W ogóle nie za bardzo czaję o co tu biega. Wiem tylko, że działa gdy jest link do innej strony.
Jak w stronie dam tylko np. echo "test"
To i tak mam pusto.