2017-08-15 8 views
0

私は投稿を使ってこのajaxスクリプトに新しい変数を追加する方法

のようにgetID.phpスクリプトにidを送る必要がある$ topidという変数で私の PHPスクリプトから値を送ることができる必要があります
$(document).ready(function(){ 

    // Load more data 
    $('.load-more').click(function(){ 
     var topid = Number($('#topid').val()); 
     var row = Number($('#row').val()); 
     var allcount = Number($('#all').val()); 
     row = row + 3; 

     if(row <= allcount){ 
      $("#row").val(row); 

      $.ajax({ 
       url: 'getData.php', 
       type: 'post', 
       data: {row:row}, 
       beforeSend:function(){ 
        $(".load-more").text("Loading..."); 
       }, 
       success: function(response){ 

        // Setting little delay while displaying new content 
        setTimeout(function() { 
         // appending posts after last post with class="post" 
         $(".post:last").after(response).show().fadeIn("slow"); 

         var rowno = row + 3; 

         // checking row value is greater than allcount or not 
         if(rowno > allcount){ 

          // Change the text and background 
          $('.load-more').text("Hide"); 
          $('.load-more').css("background","darkorchid"); 
         }else{ 
          $(".load-more").text("Load more"); 
         } 
        }, 2000); 


      } 
     }); 
    }else{ 
     $('.load-more').text("Loading..."); 

     // Setting little delay while removing contents 
     setTimeout(function() { 

      // When row is greater than allcount then remove all class='post' element after 3 element 
      $('.post:nth-child(3)').nextAll('.post').remove().fadeIn("slow"); 

      // Reset the value of row 
      $("#row").val(0); 

      // Change the text and background 
      $('.load-more').text("Load more"); 
      $('.load-more').css("background","#15a9ce"); 

     }, 2000); 


    } 

}); 

});

しかし、何とか私が必要とするのは、idがgetData.phpスクリプトに送られて、それから$ topid = $ _POST ['topid']のようなポストで取得されることだけです。

答えて

0

あなたは

data: {topid : topid} 
+0

のようなものにgetData変更

data: {row:row} 

topidを送っする必要がある場合、私はあまりにもが、その後、私はそれをエコーし​​ようとした何の値が渡さされていないことをやりました –

関連する問題