目前我以前所有人都可以使用相同的方法获取id但是在这里我无法获取url id?
pageMore.php是一个功能页面,用于加载更多页面
$(document).ready(function(){
$('.page-message-container').scroll(function(){
if($(this).scrollTop()>0){
$('.load-more-data').fadeOut();
}
else{
$('.load-more-data').fadeIn();
}
});
$("#load_more_message").click(function(){
loadmore();
});
});
function loadmore(){
var loadmoreoldmessage = document.getElementById("more_message").value;
var pageID = (location.search.match(/pageID=(\d+)/) || [])[0];
$.ajax({
type:'post',
url:'pageMore.php?'+ pageID,
data:{
getresult:loadmoreoldmessage
},
success:function(response){
var loadmore = document.getElementById("chatroom-message-container");
loadmore.innerHTML = response + loadmore.innerHTML;
document.getElementById("more_message").value = Number(loadmoreoldmessage)+10;
}
});
}
我也将$pageID=$_GET['pageID'];
放在我的pageMore.php
答案 0 :(得分:0)
示例:如果您使用type:"get"
$.ajax({
type:'get',
url:'pageMore.php?pageID='+ pageID +'&getresult='+loadmoreoldmessage,
success:function(response){
var loadmore = document.getElementById("chatroom-message-container");
loadmore.innerHTML = response + loadmore.innerHTML;
document.getElementById("more_message").value = Number(loadmoreoldmessage)+10;
}
});
在pageMore.php中使用
$pageID=$_GET['pageID'];
$getresult=$_GET['getresult'];
示例:如果您使用type:"post"
$.ajax({
type:'post',
url:'pageMore.php',
data:{
pageID:pageID,getresult:loadmoreoldmessage
},
success:function(response){
var loadmore = document.getElementById("chatroom-message-container");
loadmore.innerHTML = response + loadmore.innerHTML;
document.getElementById("more_message").value = Number(loadmoreoldmessage)+10;
}
});
在pageMore.php中使用
$pageID=$_POST['pageID'];
$getresult=$_POST['getresult'];
关于 pageID 正则表达式,如果它不起作用,请检查此answer