title: parse error syntax error unexpected token on simple AJAX
body: <p>Im a beginner in AJAX &amp; javascript, so please bear with me.</p>
  
  <p>I want to pass a variable (<code>document.getElementById('txtSearch').value</code>) from my AJAX to a PHP so i tried to code something like this :</p>
  
  <pre><code>$("#btnSearch").click(function() {
              var keyword = "";
              alert(document.getElementById('txtSearch').value);
              $.ajax({
                  url: BASE_URL + 'index.php/jwm/search', //This is the current doc
                  type: "POST",
                  dataType:'json', // add json datatype to get json
                  data: ({keyword: document.getElementById('txtSearch').value}),
                  error : function(jq, st, err) {
                      console.log(arguments);
                      alert(st + " : " + err);
                  },
                  success: function(data){
                      alert(data);
                  }
              });  
          }); 
  </code></pre>
  
  <p>However, i got an error : <code>parse error syntax error unexpected token &lt;</code> and sometimes the error change a little bit to be like this : <code>parse error syntax error unexpected token T</code>.</p>
  
  <p><strong>EDIT</strong>
  This is my PHP code :</p>
  
  <pre><code>function search() {
          $keyword = $_POST['keyword'];
          echo "TEST : $keyword";
          $result = $this-&gt;jwm_m-&gt;getDataByKeyword('msmall', $keyword);
          header('Access-Control-Allow-Origin: *');
          header('Access-Control-Allow-Methods: GET, POST');  
          header('Content-type: application/json', true);
          echo json_encode($result);
      }
  </code></pre>
  
  <p>This is what my console get :</p>
  
  <pre><code>arguments: null
  caller: null
  length: 0
  name: ""
  </code></pre>
  
  <p><strong>My goal is to passing</strong> <code>document.getElementById('txtSearch').value</code>, please help me out.</p>
  
  <p>Thanks for your help :D</p>