Skip to content Skip to sidebar Skip to footer

Page Refreshing Multiple Times While Clicking On Next Or Previous Button

I've a couple of pop-up to display the user list which would display 10 results per page, which is working fine. I'm getting the page nos. from the java servlet in the JSON. While

Solution 1:

Try this:

   $('.next-btn').unbind("click").on("click",function(){ // Give buttons an ID (include them in HTML as hidden)userList(currentPageNo+10);
         adminList(currentPageNo+10);
        });
    $('.prev-btn').unbind("click").on("click",function(){
        userList(currentPageNo-10);
        adminList(currentPageNo-10);
    });

I think click event is getting binded multiple times which is making multiple refresh, so unbind and then add event onclick.

Solution 2:

Add the following to your Next button event listener. Maybe the same for Previous too:

$('.next-btn').click(function(e){ 
e.preventDefault();         
userList(currentPageNo+10);
        adminList(currentPageNo+10);

    });

Post a Comment for "Page Refreshing Multiple Times While Clicking On Next Or Previous Button"