大佬教程收集整理的这篇文章主要介绍了jQuery Ajax每30秒请求一次,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
您可以将代码放在这样的单独函数中:
function LoadFinance()
{
$(function() {
$.getJsON(
"http://query.yahooAPIs.com/v1/public/yql?q=SELEct%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22%5EFTSE%22)%0A%09%09&format=Json&env=http%3A%2F%2Fdatatables.org%2falltables.env&callBACk=?",
function(Json){ $('#finance').text(Json.query.results.quote.ChangE);
// Patching payload into page element ID = "dog"
});
});
}
然后设置一个计时器,每30秒调用一次该函数:
seTinterval( LoadFinance, 30000 );
祝好运!;)
我有这段代码,但是当有人在我的网站上时,值可能会更改。我需要每30秒左右更新#finance div。能做到吗?
$(function() {
$.getJSON(
"http://query.yahooapis.com/v1/public/yql?q=SELEct%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22%5EFTSE%22)%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2falltables.env&callBACk=?",function(json){
$('#finance').text(json.query.results.quote.ChangE);
// Patching payload into page element ID = "dog"
});
});
以上是大佬教程为你收集整理的jQuery Ajax每30秒请求一次全部内容,希望文章能够帮你解决jQuery Ajax每30秒请求一次所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。