Skip to content

Instantly share code, notes, and snippets.

@gouthambs
Created May 28, 2014 14:38
Show Gist options
  • Save gouthambs/b3a984f7387267037fbe to your computer and use it in GitHub Desktop.
Save gouthambs/b3a984f7387267037fbe to your computer and use it in GitHub Desktop.
CORS Example with YQL
<!-- Serve this file, for example "python -m SimpleHTTPServer"-->
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
var symbol='yhoo';
$.getJSON("http://query.yahooapis.com/v1/public/yql",
{
q : "select * from yahoo.finance.stocks where symbol='"+symbol+"'",
env :"store://datatables.org/alltableswithkeys",
format: "json"
},
function (data) {
if (data.query.results) {
var txt = data.query.results.stock.symbol + '\n' +
data.query.results.stock.Sector + '\n' +
data.query.results.stock.Industry;
$("#result").text(txt);
} else {
alert('no such code: ' + code);
}
}
);
</script>
</head>
<body>
<div id="result"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment