非同期の最終解決策-ES 7のAync/Await

1321 ワード

非同期のソリューション-ES 7のAync/Await
$(document).on('click','.fenlei,.ckgd',async function(){
	var href = $(this).attr('value');
	var typetitle = $(this).attr('title');
	if(href == ''){
		$("#recommendation").show();
	}else{
		$("#recommendation").hide();
	}
	$('.fenlei').css('background-color','');
	$(".fenlei[value^='"+href+"']").css('background-color','#abc');
	if(href == ''){
		videoAll()
		$(".resrec").show();
	}else{
		var cnum = await countnum(href);
		LoadPageTZRL(href,typetitle,cnum);
	}
});
async function videoAll() {
    $("#expert").empty();
    wilddog.sync().ref('').orderByChild('update_time').limitToLast(homepagesize).on("child_added", function (recommenddata) {
        let n = recommenddata.val();
        let i = recommenddata.key();
        var rechtml = "";
        $("#expert").prepend(rechtml);
    });
    var menulength = menuArr.length;
    $(".djt").empty();
    for (var j=0; j