我想使用jquery中的ajaxStop函数,但无法触发它,有什么建议吗?
我的目标是循环遍历每个锚点(anchor)标签,然后更新其中的一些内容,接下来我想使用ajaxstop事件来触发一个脚本,以根据更新重新组织这些锚点。
谢谢您的帮助。
我的目标是循环遍历每个锚点(anchor)标签,然后更新其中的一些内容,接下来我想使用ajaxstop事件来触发一个脚本,以根据更新重新组织这些锚点。
谢谢您的帮助。
jQuery(document).ready(function($) {
function updateUsers() {
$(".twitch_user").each(function(index, user) {
$.ajax({ url: "https://api.twitch.tv/kraken/streams/" + $(user).attr("id") + "?callback=?", success: function(d) {
if(d.stream) {
$(user).addClass("online");
$(user).removeClass("offline");
$(user).children(".viewers").text(d.stream.viewers + " viewers");
} else {
$(user).addClass("offline");
$(user).removeClass("online");
$(user).children(".viewers").text("0 viewers");
}
console.log(d);
}, dataType: "json"});
});
}
//$(document).ajaxStart(function() {
// console.log("Event fired!");
// updateUsers().delay(2000);
//})
$(document).ajaxStop(function() {
console.log("Event fired!");
// updateUsers().delay(2000);
});
updateUsers();
});