簡體   English   中英

如何使用jquery通過ajax使用loader和html內容

[英]how to use loader and html content via ajax using jquery

這是我的代碼

   $('#loader').hide()
   .ajaxStart(function(){
     $(this).show();
   })
   .ajaxStop(function(){
     $(this).hide();
   });


   $('form#jobsearch').submit(function(){
      $("div.job-search-content").hide();
      $("div#pagination").hide();

       $.ajax({
          type: "POST",
          url: "classes/ajax.simplesearch.php",
          data: $('form#jobsearch').serialize(),
          success: function(data){
          // I DONT" REALLY KNOW WHAT TO DO IN THIS PART 
            $(data).insertAfter('#job-search-headings').html();
              //$("div.job-search-content").show();
          }
       });
        return false;
   });
});

如果我隱藏了job-search-content div,它將顯示加載器,但問題是,如何在'#job-search-headings'div下添加檢索到的數據庫內容? ....我檢查了firebug ..我能夠檢索到正確的數據..但我無法在前端顯示它:(

如果你想在div“job-search-content”上顯示ajax結果

$("div.job-search-content").html(data).show();

數據是您發布到的頁面的響應,因此如果頁面返回類似<div>some content</div>更改

$(data).insertAfter('#job-search-headings').html();

$('#job-search-headings').after(data);

嘗試這樣的事情:

$('#job-search-headings').after(data);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM