Created
May 28, 2014 14:38
-
-
Save gouthambs/b3a984f7387267037fbe to your computer and use it in GitHub Desktop.
CORS Example with YQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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