Welcome Guest, Not a member yet? Register   Sign In
Pagination Links doesnt work with Jquery's AJAX problem.
#1

[eluser]Katsune[/eluser]
Hey guys, I'm currently working on a ajax pagination using the default pagination class, so far the page moves, my only problem is that the link doesnt change the <strong> tag to the selected link, also I cant click the first link, but I can click the rest of the links, here's my code:
Controller:
Code:
public function recordsFromJSCall(){
        //checks session status
        if($this->session->userdata('is_logged')){
        $config['base_url']='http://localhost/AnimeInventory/index.php/maincontroller/records';
        $config['total_rows'] = $this->db->get('detail')->num_rows();
        $config['per_page'] = 5;
        $config['num_links'] = 2;
        $config['uri_segment'] = 3;
        $config['anchor_class'] = "class = 'paginationLinks' id = 'paginationID' ";
        $this->pagination->initialize($config);
        $page = array('page'=>$this->input->post('page'));            
        $offsetValue = ($page['page'] -1) * $config['per_page'];
        if($offsetValue >0){
        $data['getRecords'] = $this->inventoryModel->selectData($offsetValue);        
        $data['link']=$this->pagination->create_links();
        $endArrayPointer = end($data['getRecords']);
        echo json_encode($data['getRecords']);
        echo json_encode($data['link']);
        }
        }
    else {
        $this->authenticate();
        }
    }
jquery:
Code:
$(document).on('click','#paginationID',function(){
     var page = $(this).text();
    $.ajax({
           type:'POST',
           url: 'http://localhost/AnimeInventory/index.php/maincontroller/recordsFromJSCall',
           data: {page : page},
           dataType:'JSON',
           success:function(smg){
                       $('.actualResults').remove();
                      // $('.linkRow').remove();        
                       $.each(smg, function(i) {
                       $('.ResultTable').append('<tr  class="actualResults"><td>' + smg[i].Title + '</td><td>' + smg[i].EntryDate + '</td>\n\
                       <td>' + smg[i].id + '</td><td>' + smg[i].GenreName+ '</td></tr>' );
                       });
                       console.log(smg['link']);
                       $('#linkTable').append('<tr id="linkTable"><td></td></tr>');
           }            
    });
       return false;
  
});

Maybe someone here had the same problem before?

Thanks,
#2

[eluser]InsiteFX[/eluser]
For one you need a / on the end of both of your url links.

If you can not get it to work get hold of me on Skype, I have jQuery modified CI pagination class for it that works.




Theme © iAndrew 2016 - Forum software by © MyBB