What is the proper way of doing long polling using jQuery and AJAX

后端 未结 2 1861
离开以前
离开以前 2021-02-09 11:43

I have a project which involves live notification. So I stumbled upon using socket io but I didn\'t have enough time to learn it yet. So I tried doing it with AJAX and jQuery. B

2条回答
  •  情深已故
    2021-02-09 12:21

    Please refer : Jquery : Ajax : How can I show loading dialog before start and close after close?

    I hope this could help you

    $("div.add_post a").click(function(){
    
      var dlg = loadingDialog({modal : true, minHeight : 80, show : true});
                dlg.dialog("show");
      $.ajax({
            url : "/add.php",
            complete : function (){
                dlg.dialog("hide");
            }
         });
     return false;
    });
    
    
    //--Loading dialog
    
    function loadingDialog(dOpts, text = "пожалуйста подождите, идет загрузка...")
    {
        var dlg = $("
    загрузка "+text+"
    ").dialog(dOpts); $(".ui-dialog-titlebar").hide(); return dialog; }

提交回复
热议问题