title: ajax no response in codeigniter
body: <p>I tried to take some simple exercise about ajax in CI.
  But no response... I had tried to set the breakpoint alert("aa") and it failed; 
  But the alarm is worked ahead or behind the ajax code.
  Could some one help to fix it?Many thanks.
  Here is the code</p>
  
  <pre><code>View
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;!-- ajax example--&gt;
  &lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  function AJAX_call() {
  a_val  = $('[name="a"]').val();
  b_val  = $('[name="b"]').val();
  
  AJAX_url = '&lt;?php echo base_url()."index.php/ajax_example/AJAX_calc";?&gt;';
  
  $.ajax({
  type: "POST",
  url : AJAX_url,
  data:  {a : a_val,  b : b_val },
  dataType: "json",
  success: function(data2) {alert("aa");$('#result').html(data2.result); }
  }); 
  
  }&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form onsubmit="AJAX_call();"&gt;
  &lt;label&gt;Enter A&lt;/label&gt;
  &lt;input type="text" name="a" /&gt;
  &lt;label&gt;Enter B&lt;/label&gt;
  &lt;input type="text" name="b" /&gt;
  Result:
  &lt;div id='result'&gt;The Result Will Be Shown Here&lt;/div&gt;
  &lt;input type="submit" value="Calculate" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>&lt;?php 
  
  class Ajax_example extends CI_Controller {
      function __construct(){
          parent::__construct();
      }
      public function index()
      {
      $this-&gt;load-&gt;helper('url');
      $view_params="";
              $this-&gt;load-&gt;view('ajax_view',$view_params);
      }
      function AJAX_calc() {
  
  
  if (!$this-&gt;input-&gt;is_AJAX_request()) exit ('none AJAX calls rejected!'); 
  
  
  $a = $this-&gt;input-&gt;post('a');
  $b = $this-&gt;input-&gt;post('b');
  $result = (int) $a * (int) $b; 
  $data = array('result'=&gt; $result);
  echo json_encode($data);
  return;
  
  }
  }
  </code></pre>