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);
}
});
在您的Ajax调用期间,使用type : 'get'
或在search-data.php中使用$_POST
Superglobal来获取数据。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.