我有一个按钮,可以将您重定向到最后一页。
但是当它转到 news.php?page = 1& search = s 时,我收到错误。
错误看起来像http://i.gyazo.com/357a1bd5468a5e77a81ad53c7882093d.png
脚本。
的script.js
$(document).ready(function() {
$('#back').on('click', function(e) {
$.ajax({
url: 'ajax/back.php',
success: function(data) {
var search = getUrlVars()['search'];
if(typeof(search) === 'undefined') {
window.location = "news.php?page="+data;
} else {
if(search.length > 0) {
window.location = "news.php?search="+search+"&page="+data;
} else {
window.location = "news.php";
}
}
}
});
})
});
back.php
<?php
session_start();
if(isset($_SESSION['last_page'])) {
echo $_SESSION['last_page'];
} else {
echo 1;
}
$_SESSION['last_page'] = array();
?>
答案 0 :(得分:0)
进行后页更改,
window.location = "news.php?search="+search+"&page="+data;
到
parent.history.go(-1);
答案 1 :(得分:0)
我想我已经找到了循环。
news.php
if (isset($_GET['page'])) {
$page = mysql_real_escape_string($_GET['page']);
if($page < 1 || $page > $total_pages) {
header("Location: news.php?page=1&search=$search");
}
} else {
$page = 1;
}
$ total_pages = 2(这取决于我有多少寻呼机,每页6个新闻,我有8个,所以它是2个。