title: i want to send data from js to php
body: <p>I want to send data from JS file to PHP file where a function receives this data and performs further actions on it. But the problem is that the data isn't receiving from JS to controller function.</p>
  
  <p><strong>JS code:</strong></p>
  
  <pre><code>$("#mybtn").click(function(){
  
    $.post(&lt;?= base_url()?&gt;+"upload",{a1: $('#a1').val(), a2: 
    $('#a2').val(), a3: $('#a3').val(), a4: $('#a4').val(),a5: 
    $('#a5').val()},function(data) {
    });
  
  });     
  </code></pre>
  
  <p><strong>Controller function:</strong> </p>
  
  <pre><code>function upload() {
  
    echo "this is upload";
  
    $data = array(
      'name' =&gt; $this-&gt;input-&gt;post('a1'),
      'email' =&gt; $this-&gt;input-&gt;post('a2'),
      'pass' =&gt; $this-&gt;input-&gt;post('a3'),
      'amnt' =&gt; $this-&gt;input-&gt;post('a4'),
      'pcode' =&gt; $this-&gt;input-&gt;post('a5')
    );
  
    $result = $this-&gt;pages_m-&gt;upload($data);
  
    var_dump($data);
  
  }
  </code></pre>