JQuery 的简单练习

面对闪存太多的情况,想要删除闪存,在"我的"栏目中使用以下脚本:

        setInterval('refreshQuery()',5000); 

function refreshQuery(){
   var str = $(".recycle").attr("onclick");
   
   var ingId = str.substring(str.indexOf("(")+1, str.indexOf(")"));
   console.log(ingId);
   
   $.ajax({
            url: '/ajax/ing/del',
            data: { 'ingId': ingId },
            type: 'post',
            dataType: 'text',
            // contentType: 'application/json; charset=utf-8',
            success: function (data) {
                if ($("#ing_body_" + ingId).length) {
                    $("#ing_body_" + ingId).css("color", "red");
                    $("#ing_body_" + ingId).html(data);
                    $("#feed_content_" + ingId + " a.recycle").hide();
                }
                else {
                    $("#ing_detail_body").css("color", "red");
                    $("#ing_detail_body").html(data);
                }
            },
            error: function (xhr) {
            }
        });
   
}

 

posted @ 2019-01-31 15:55  zycyc  阅读(162)  评论(0编辑  收藏  举报