weixin_33709609 2017-11-24 00:30 采纳率: 0%
浏览 64

禁用ajax提交按钮

I have the following JS and HTML code and I want to disable the button when ajax request is submitting so the user wont be able to double click and disturb the process.

function doReshare(_intPostId) {
if(typeof cLogin === 'undefined')
    var cLogin = checkLogin();
if(cLogin!=true)
    return;
var date = new Date();
var mainId = _intPostId;
var type = 1;
var active = 0;
var postFinded = 0;
jQuery(".reshare_" + _intPostId).each(function() {
    postFinded = 1;
    objElement = jQuery(this);
    if(objElement.hasClass('sm2_playing') || objElement.hasClass('sm2_paused')) {
        // track is active
        active = 1;
    }
    if(objElement.hasClass('is_album')) {
        mainId = objElement.closest('div.playlist-box').attr('id').replace('album_', '');
        // mainId = objElement.data('mainid');
    }
    var intLikesCurrentCount = parseInt(objElement.find(".likes_count").first().text(), 10);
    if(!objElement.find(".refeed_fct").hasClass("active")) {
        if(active)
            jQuery('.player-icons.dorepost').addClass('active');
        objElement.find(".refeed_fct").addClass("active");
        //objElement.find(".likes_count").html("<i class=\"fa fa-heart-o\"></i> " + (intLikesCurrentCount + 1));
    } else {
        objElement.find(".refeed_fct").removeClass("active");
        if(active)
            jQuery('.player-icons.dorepost').removeClass('active');
        type = 0;
        //objElement.find(".likes_count").html("<i class=\"fa fa-heart-o\"></i> " + (intLikesCurrentCount - 1));
    }
});
if(!postFinded) {
    if(!jQuery(".player-icons.dorepost").hasClass("active")) {
        jQuery('.player-icons.dorepost').addClass('active');
    } else {
        jQuery('.player-icons.dorepost').removeClass('active');
    }
} 
jQuery("#vowave").append('<img width="1" height="1" src="/reshare/' + mainId + '/' + type + '?time=' +  date.getTime() + '" />');

}

and the html

<span class="refeed_fct" onclick="doReshare(10309)">
<i class="fa fa-retweet"></i> <div class="inline hidden-mobile">Repost</div>
</span>

Thank you

  • 写回答

1条回答 默认 最新

  • ?Briella 2017-11-24 00:34
    关注

    Maybe you should set the objElement's onclick listener to an empty function

    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀