title: Adding data using codeigniter and ajax
body: <p>I am new in codeigniter I want to retrieve data into table using ajax 
  but no result found please help me to solve my problem</p>
  
  <p><strong>this is controller code</strong></p>
  
  <pre><code>public function indexajax()
        {
  
  
            $this-&gt;load-&gt;model("usersmodel");
           $data['pagetitle']=" --&gt;All Users Using Ajax&lt;--";
  
  
  
           $this-&gt;load-&gt;view("template/admin/header");
            $this-&gt;load-&gt;view("users/allusersusingajax");
  
            $this-&gt;load-&gt;view("template/admin/footer");
  
        }
        public function get_all_users()
        {
           if($this-&gt;input-&gt;post("action")=='FetchAllUserUingAjax1'){
  
                $this-&gt;load-&gt;model("usersmodel");
               // print_r($this-&gt;input-&gt;post("action"));
                echo ($this-&gt;input-&gt;post("action"));
                $data["allu"]=$this-&gt;usersmodel-&gt;ShowAllUsers("users");
   foreach ($allu as $a):
          echo'&lt;tr&gt;
              &lt;td&gt;'.$a-&gt;id.'&lt;/td&gt;
              &lt;td&gt;'.$a-&gt;username.'&lt;/td&gt;
             &lt;td&gt;&lt;button class="deletenew" id="'.$a-&gt;id.'"&gt;deletenew&lt;/button&gt;&lt;/td&gt;
  
          &lt;/tr&gt;';
          endforeach;
  
  
  
            }
  
  
  
  
        }
  
  
  }
  </code></pre>
  
  <p><strong>this is my model code</strong></p>
  
  <pre><code>public function ShowAllUsers()
          {
              //$this-&gt;db-&gt;order_by("id", "desc");
          //  $this-&gt;db-&gt;limit(20);
              $sql=$this-&gt;db-&gt;get("users");
              return $sql-&gt;result();
  
          }
  </code></pre>
  
  <p>This is my view code</p>
  
  <p><strong>this is my HTML</strong> </p>
  
  <pre><code>&lt;div class="userdataajax table-responsive"&gt;
      &lt;table class=" table table-responsive table-bordered"&gt;
          &lt;tr&gt;
              &lt;th&gt;#&lt;/th&gt;
              &lt;th&gt;name&lt;/th&gt;
              &lt;th&gt;image&lt;/th&gt;
              &lt;th&gt; full name&lt;/th&gt;
              &lt;th&gt;email&lt;/th&gt;
              &lt;th&gt;usertype&lt;/th&gt;
              &lt;th&gt;status&lt;/th&gt;
              &lt;th&gt;reg date&lt;/th&gt;
              &lt;th&gt;reg time&lt;/th&gt;
              &lt;th&gt;delete&lt;/th&gt;
              &lt;th&gt;edit&lt;/th&gt;
              &lt;th&gt;Activate&lt;/th&gt;
              &lt;th&gt;disactivate&lt;/th&gt;
  
          &lt;/tr&gt;
  
  
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>this is my ajax calling trying to  retrieve and delete data</strong></p>
  
  <pre><code>&lt;script&gt;
  
      $(document).ready(function () {
          FetchAllUserUingAjax();
  
          function FetchAllUserUingAjax() {
  
              $.ajax({
                  url:'&lt;?php echo base_url()?&gt;Users/get_all_users',
                  method:"post",
  
                  success:function (data) {
                      $(".userdataajax table").append(data);
  
                  }
              })
              var action="FetchAllUserUingAjax1";
              $.ajax({
                  url:"&lt;?php echo base_url()?&gt;Users/get_all_users",
                  method:"post",
                  data:{action:action},
                  success:function (data) {
                      $(".userdataajax table tr ").not("table tr:first").remove();
                      $(".userdataajax table").append(data);
                      Table();
  
  
                  }
              })
  
          }
  /******************/
          $(".deletenew").on("click",function () {
              var id=$(this).attr('id');
              $.ajax({
                  url:'&lt;?php echo base_url()?&gt;Users/deleteusers',
                  method:"post",
                  data:{id:id},
                  success:function () {
                      FetchAllUserUingAjax();
  
                  }
  
              })
          })
  
      })
  
  &lt;/script&gt;
  </code></pre>