I'm trying to make an ajax call to get result from my database, but i'm facing an error.
My javascript:
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
- <script language="Javascript">
- setTimeout(makeAjaxCall, 1000);
- function makeAjaxCall(){
- $.ajax({
- type: "post",
- url: "call/update",
- cache: false,
- data: {action: 'getUpdate', term: '<?php echo $id;?>'},
- success: function(json){
- try{
- var obj = jQuery.parseJSON(json);
- alert( obj['STATUS'] + obj['results']);
-
-
- }catch(e) {
- alert('Exception while request..');
- }
- },
- error: function(){
- alert('Error while request..');
- }
- });
- }
- </script>
And my controller's method:
- public function update()
- {
- if (isset($_POST['action'])){
- if ($_POST['action'] == 'getUpdate'){
- pollNewData();
- }
- }
-
- function pollNewData(){
- $term = $_POST['term'];
- $query = $this->db->query("SELECT * FROM users where guid <> '' and user_id = '$term'");
- $res = $query->result();
- echo json_encode(array('STATUS'=>200, 'results'=>$res));
- }
-
- }
i have this error on chrome debugs tool:
500 (Internal Server Error)