So i have a picture gallery with eight categories. Each category has 400+ images, these subcategories are called there by AJAX. I also have a pagination system in the subcategories. Currently i have 8 ajax calls, which is useless, so i'd like to shrink them into one by giving 2 arguements: 'lap' which tells it which page it's on, if lap == 0 or null it gives the normal page, else it gives oldal+?page= + lap. 'Oldal' is the second arguement, it is used at the first category selection where it tells the browser which php file to open(kepek_kat1.php or kepek_kat2 ... kepek_kat8.php). 'Oldal' works great with opening the categories, going into the subcategories, but the pagination doesn't work. Here is my code of the 8 caregories:
<div id="kepek">
<div class="kepkat"><a href="#amator" onclick="mutikat(null,'../php/kepek_kat1.php');"><img src="../img/kepkat/amator.jpg" height="130px" width="90px" alt="Amatőrök"/><br/>Amatőr</a></div></div> <!-- only showing the first selection -->
So the first arguement is null, which gives it the page without pagination.
Here is my subcategory code:
echo "<div class='lapozo'><a onclick='mutikat($page, '../php/kepek_kat1.php');' href='../html/blog.php#amator?page=$page'>$page</a></div>"; }
The $page is in a loop, it lists which page it is currently on, it displays the page controls.
Here is my ajax call:
function mutikat(lap, oldal)
{
//create XMLHttpRequest object
xmlHttpRequest = (window.XMLHttpRequest) ?
new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
//If the browser doesn't support Ajax, exit now
if (xmlHttpRequest == null)
return;
if(lap == 0 || lap === 0 || lap == null )
{
//Initiate the XMLHttpRequest object
xmlHttpRequest.open("GET", oldal, true);
}
else
{
xmlHttpRequest.open("GET", oldal + '?page=' +lap, true);
}
//Setup the callback function
xmlHttpRequest.onreadystatechange = StateChange;
//Send the Ajax request to the server with the GET data
xmlHttpRequest.send(null);
}
function StateChange()
{
if(xmlHttpRequest.readyState == 4)
{
document.getElementById('kepek').innerHTML = xmlHttpRequest.responseText;
}
}
there are 8 ajax calls. Please help me!
Thanks a lot!