I want to click the checkbox to display the database filed values in codeigniter
<p>I want to click checkbox to show the data what i want fetch through ajax call, but it is showing database all data automatically show whats the problem please find out and help me (just i want ajax call) </p>

<p><strong>Controller</strong></p>

<pre><code>//This is my controller
public function laptops()
{
$this-&gt;load-&gt;model('feature_model');
$filter = array(
    'price' =&gt; $this-&gt;input-&gt;get('price'),
    'name' =&gt;$this-&gt;input-&gt;get('name')
);
$data['laptop'] = $this-&gt;feature_model-&gt;laptops_m($filter);

//echo json_encode($this-&gt;feature_model-&gt;laptops_m($filter));
$this-&gt;load-&gt;view('feature/checkbox',$data);
} 
//This is my model
 function laptops_m($filter = null){
    $this-&gt;db-&gt;select('*')
             -&gt;from('mobile_phones');
   // $query = $this-&gt;db-&gt;get('laptop_notebook')-&gt;result();
   // return $query;
    if($filter['name']){
        $this-&gt;db-&gt;where('name', $filter['name']);
    }
    if($filter['price']){
        $this-&gt;db-&gt;where('price', $filter['price']);
    }
    $query = $this-&gt;db-&gt;get()-&gt;result();

    return $query;

}
//This is my view
&lt;input type="checkbox" name="name" value="acer"&gt;  


&lt;input type="checkbox" name="name" value="lenovo"&gt;    

&lt;input type="checkbox" name="price" value="1000"&gt;   



 &lt;table&gt;
        &lt;tbody&gt;
        &lt;?php foreach ($laptop as $laptops_all) { ?&gt;
            &lt;tr&gt;

                &lt;td&gt;&lt;p&gt;Laptop &lt;?php echo $laptops_all-&gt;name ?&gt; &lt;/p&gt;
                &lt;/td&gt;


            &lt;/tr&gt;
        &lt;?php } ?&gt;
        &lt;/tbody&gt;
    &lt;/table&gt;  
</code></pre>

<p><strong>Ajax script:</strong></p>

<pre><code>//  This is the ajax script function
&lt;script&gt;
$("input[checkbox]").change(function(){
               $.ajax({
            url: localhost/ci35/feature/laptops,
            dataType: 'json',
            success: function(data){
                $.each(data, function(index, element) {
                    $("tbody").empty();
                    $("tbody").append("&lt;tr&gt;&lt;td&gt;"+
                    "Laptop "+element.brand+""+
                    "&lt;/td&gt;&lt;/tr&gt;");
                });
            }
        }); 
</code></pre>