Display loading image while post with ajax

前端 未结 7 1834
野趣味
野趣味 2020-12-07 17:18

I know there are thousands of examples on the internet, but I want for the script I already have to display a loading gif image while the data is retrievedd. My java knowled

7条回答
  •  猫巷女王i
    2020-12-07 17:44

    This is very simple and easily manage.

    jQuery(document).ready(function(){
    jQuery("#search").click(function(){
        jQuery("#loader").show("slow");
        jQuery("#response_result").hide("slow");
        jQuery.post(siteurl+"/ajax.php?q="passyourdata, function(response){
            setTimeout("finishAjax('response_result', '"+escape(response)+"')", 850);
                });
    });
    
    })
    function finishAjax(id,response){ 
          jQuery("#loader").hide("slow");   
          jQuery('#response_result').html(unescape(response));
          jQuery("#"+id).show("slow");      
          return true;
    }
    

提交回复
热议问题