Jump to content

Ajax in Codeigniter Issue


msz

Recommended Posts

I am trying to refresh / reload the page using ajax.

 

View:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Insert | SP</title> <script src="<?php echo base_url(); ?>bootstrap/js/jquery-2.1.1.min.js"></script> <script> $(document).ready(function(){ function loadNowPlaying(){ $(this).load('<?php echo base_url().'Store/student' ;?>'); } setInterval(function(){loadNowPlaying()}, 5000); }); </script> </head> <body> <form action="<?php echo base_url();?>Store/add" method="post"> <input type="text" name="name" id="name"><br> <input type="text" name="mail" id="mail"><br> <input type="password" name="pass" id="pass"><br> <input type="submit" name="submit" id="submit" value="Insert"> </form> <table id="studata"> <?php foreach ($students as $student):?> <tr> <th>Name</th> <th>Email</th> <th>Password</th> </tr> <tr> <td><?php echo $student->Name;?></td> <td><?php echo $student->Email;?></td> <td><?php echo $student->Password;?></td> </tr> <?php endforeach;?> </table> </body> </html>

My Controller code:

 

public function student()
{
$data["students"] = $this->sp->getstudent();
$this->load->view('student',$data);
}

My Model:

 

public function getstudent()
{
$this->db->select('*');
$this->db->from('ex_sp');
$query = $this->db->get();
return $query->result();
}

The code is working fine but it is loading my whole page [view] and i want to only load the table or some specific container but using the same view. I check a lot of question but did not find what i want, Please check the question instead of down voting. What is wrong in it? can someone please look at it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.