所有
我使用的是我在此处找到的代码:http://www.aaronjwhite.org/index.php/15-web-development/jquery/7-using-jquery-and-google-finance-to-create-a-simple-stock-ticker
我试图让它工作,它不会给我任何错误信息或任何东西。它只是没有做任何事情。
这是代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.10.2.min.js'> </script>
<script type='text/javascript'>
$(document).ready(function(){
$.getJSON('https://finance.google.com/finance/info?client=ig&q=NYSE:AIR&callback=?',function(response){
var stockInfo = response[0];
var stockString ='<div class="stockWrapper">STOCK:';
stockString +='<span class="stockSymbol">'+stockInfo.t+'</span>';
stockString +='<span class="stockPrice">'+stockInfo.l+'</span>';
stockString +='<span class="stockChange">'+stockInfo.c+'</span>';
stockString +='<span>at</span> <span class="stockTime">'+stockInfo.ltt+'</span>';
stockString +='</div>';
$('.stockTick').prepend(stockString);
}); });
</script>
</head>
<body text="#000000" bgcolor="#FFFFFF">
<form id="form1">
<div class="stockTick">Stock ticker should be here </div>
</form>
</body>
</html>
我将它保存在.htm文件中以查看它是否可行,到目前为止还没有。
答案 0 :(得分:2)
您尚未结束$(document).ready(function(){
功能:
将另一个});
添加到脚本的末尾
<script type='text/javascript'>
$(document).ready(function(){
$.getJSON('https://finance.google.com/finance/info?client=ig&q=NYSE:AIR&callback=?',function(response){
var stockInfo = response[0];
var stockString ='<div class="stockWrapper">STOCK:';
stockString +='<span class="stockSymbol">'+stockInfo.t+'</span>';
stockString +='<span class="stockPrice">'+stockInfo.l+'</span>';
stockString +='<span class="stockChange">'+stockInfo.c+'</span>';
stockString +='<span>at</span> <span class="stockTime">'+stockInfo.ltt+'</span>';
stockString +='</div>';
$('.stockTick').prepend(stockString);
});
});
</script>