Hi guys, I finished my php gallery pagination and was wondering if its possible to use ajax getXMLHTTPRequest to click the next / prev links without a page refresh.
The gallery links look like this:
next gallery.php?page=1
prev gallery.php?page=0
Now this is what I was thinking.
Making a function for getXMLHTTPRequest
Then make a new getXMLHTTPRequest();Code:<script type="text/javascript"> function getXMLHTTPRequest() { var req = false; try { req = new XMLHttpRequest(); } catch (err) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (err) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (err) { req = false; } } } return req; } </script>
Next when the second page is requested i want it to retrieve it like this:Code:<script type="text/javascript"> var screenshots = new getXMLHTTPRequest(); </script>
Im really new to ajax but I would love to know if its possible and how to do it.Code:<script type="text/javascript"> function next(id) { if (screenshots) { try { var url = "gallery.php"; var query = url + "?page=" + id; screenshots.open("GET", query, true); screenshots.send(null); } catch (e) { alert ("Unable to connect to the server:\n" + e.toString()); } } else { alert ("end"); } }
Thanks for any info ore examples.![]()


Reply With Quote
Bookmarks