I have a problem with an extremely simple feature. It is a “Next Page” button that simple only returns “undefined” whatever I do.
<script>
$(document).ready(function() {
$('#nextButton').click(function() {
rgx = /page=(\d+)/g;
page = rgx.exec(self.location)[1];
var pageNow = parseInt(page);
var pageNext = pageNow + 1;
if (page >= 1) {
var url = self.location;
self.location = url.replace('&page=' + pageNow, '&page=' + pageNext);
}
});
});
</script>
<body>
<button id="nextButton">Next</button>
</body>
The button currently redirects to a page with an undefined url ending.
Apologize in advance for taking up your time with basic questions.
I think
self.locationis a location object. Try to useself.location.hrefinstead.