0 Replies - 381 Views - Last Post: 25 August 2017 - 10:49 AM

#1 msz_900  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 41
  • Joined: 09-February 11

Ajax in codeigniter issue

Posted 25 August 2017 - 10:49 AM

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


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <title>Insert | SP</title>
      <script src="<?php echo base_url(); ?>bootstrap/js/jquery-2.1.1.min.js"></script>


            function loadNowPlaying(){
      $(this).load('<?php echo base_url().'Store/student' ;?>');
    setInterval(function(){loadNowPlaying()}, 5000);


        <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">

        <table id="studata">
           <?php foreach ($students as $student):?>
                <td><?php echo $student->Name;?></td>
                <td><?php echo $student->Email;?></td>
                <td><?php echo $student->Password;?></td>
            <?php endforeach;?>

My Controller code:

public function student()
        $data["students"] = $this->sp->getstudent();

My Model:

public function getstudent()
        $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.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1