Load to no, that is, the final display is gone, you can also click on it, and continue to display loading-style text, how to solve the problem

/ / Page load
jQuery (document) .ready (function ($) {

    var loading=false
    $("div-sharppost-read-more a").click( function() {
        if(loading)return
        loading=true
        $this = $(this);
        $this.addClass("loading").text("Loading"); //aloadingclass
        var href = $this.attr("href"); //
        if (href != undefined) { //
            $.ajax( { //ajax
                url: href, //
                type: "get", //get
                error: function(request) {
                    loading=false
                },
                success: function(data) { //
                    loading=false
                    $this.removeClass("loading").text(""); //loading
                    var $res = $(data).find(".list"); //
                    $(".box").append($res); //posts-loop
                    var newhref = $(data).find("-sharppost-read-more a").attr("href"); //
                    if( newhref != undefined ){
                        $("-sharppost-read-more a").attr("href",newhref);
                        
                    }else{
                    
                        $("-sharppost-read-more a").html("").removeAttr("href");
                        
                        
                    }
                }
    });   
}   
return false;   

});

});
loaded to no, that is, the final display is gone, you can click on it, and continue to display loading-style text. How to solve it? how to modify

?
Apr.25,2021

put loading=true,$this.addClass ('loading'). Text ("Loading"); after if (href! = undefined)

 $('div-sharppost-read-more a').click( function() {
        if(loading)return
        $this = $(this);
        var href = $this.attr("href"); //
        if (href != undefined) { //
            loading=true
            $this.addClass('loading').text("Loading"); //aloadingclass
            $.ajax( { //ajax

PS: I think it is not more appropriate to use button in your example. Using data-url to save the address of the next page, you use the a tag to feel that you want to save a url, to prevent the default jump event and to control whether it can be clicked. By contrast, button is much more suitable. When "gone", set button to disabled,data-url to save the address of the next page, properly, without ambiguity

Menu