how to add a new variable to this ajax script through post -
i need able send value php
script variable called $topid needs send id getdata.php script tried like
$(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 class="post" $(".post:last").after(response).show().fadein("slow"); var rowno = row + 3; // checking row value greater allcount or not if(rowno > allcount){ // change text , 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 greater allcount remove class='post' element after 3 element $('.post:nth-child(3)').nextall('.post').remove().fadein("slow"); // reset value of row $("#row").val(0); // change text , background $('.load-more').text("load more"); $('.load-more').css("background","#15a9ce"); }, 2000); } });
});
but somehow not seem working need id gets sent getdata.php script , through post $topid = $_post['topid '];
if need sent topid
getdata
change
data: {row:row}
into like
data: {topid : topid}
Comments
Post a Comment