My code:
var page = 1;
$(window).scroll(function () {
$('#more').hide();
$('#no-more').hide();
if($(window).scrollTop() + $(window).height() > $(document).height() - 200) {
$('#more').css("top","400");
$('#more').show();
}
if($(window).scrollTop() + $(window).height() == $(document).height()) {
$('#more').hide();
$('#no-more').hide();
page++;
var data = {
page_num: page
};
var actual_count = "<?php echo $actual_row_count; ?>";
if((page-1)* 2 > actual_count){
$('#no-more').css("top","400");
$('#no-more').show();
}else{
$.ajax({
type: "POST",
url: "search-data.php/?search=<?php echo $search ?>", // <---- Here Problem
data:data,
success: function(res) {
$("#result").append(res);
console.log(res);
}
});
}
}
});
on the file search-data.php
:
$search = $_GET['search']; // no string
Change your ajax request to GET
$.ajax({
type: "GET",
url: "search-data.php/?search=<?php echo $search ?>",
data:data,
success: function(res) {
$("#result").append(res);
console.log(res);
}
});
Thanks for your answer "Morteza"
$.ajax({
type: "GET",
url: "search-data.php/?search=<?php echo $_GET['search'] ?>&page=+data.page_num",
data:data,
success: function(res) {
$("#result").append(res);
console.log(res);
}
});
Thankyou very much :D
Regard's
Grenz
its post request change to
$search = $_POST['search'];
or change in your script
$.ajax({
type: "GET",
url: "search-data.php/?search=<?php echo $search ?>", // <---- Here Problem
data:data,
success: function(res) {
$("#result").append(res);
console.log(res);
}
});
Either during your ajax call, use type : 'get'
or in search-data.php use $_POST
Superglobal to fetch the data.