我知道之前曾经问过同样的问题,但无论我阅读和尝试过什么,我都无法让我的代码工作......我仍然有点像菜鸟我有这种感觉我做错了
所以,现在我的限制为10.我希望当我点击按钮'查看更多'时,限制为50,而不刷新页面。
这是我的HTML:
<?php
require_once 'php/connection.php';
include 'includes/head.php';
?>
<body>
<?php include 'includes/header.php'; ?>
<section class="wrapper" id="projectshow">
<?php
$limit = '10';
$query = mysql_query("SELECT * FROM expodetails order by rating desc LIMIT $limit");
$counter = 1;
while($row = mysql_fetch_array($query)){
$id = $row['id'];
$projectname = $row['projectname'];
?>
<article class="project-wrapper">
<div class="project">
<h3><?php echo "$projectname"; ?></h3>
</article>
<?php
}
?>
<a href="#" class="submit viewmore" onclick="bekijkmeer('a');">View more</a>
</section>
</body>
这是我的文件名为ajax.js:
function check(){
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
return xmlHttp;
}
function bekijkmeer(x)
{
var xmlHttp = check();
xmlHttp.open("GET","/expoproject/php/changelimit.php?appeltje="+x+"",true);
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById('topchange').innerHTML=xmlHttp.responseText;
}
}
xmlHttp.send(null);
}
这是我的名为changelimit.php的文件:
<?php
$limit = '50';
$query = mysql_query("SELECT * FROM expodetails order by rating desc LIMIT $limit");
$counter = 1;
while($row = mysql_fetch_array($query)){
$id = $row['id'];
$projectname = $row['projectname'];
?>
<article class="project-wrapper">
<div class="project">
<h3><?php echo "$projectname"; ?></h3>
</article>
<?php
}
?>