0

JavaScriptファイルから間隔関数を呼び出しています。コードは次のとおりです

setInterval(function() {
  $.getJSON('/home/trackUnreadMsgs', function(result) {
    $.each(result, function(i, field) {
      var temp = "#messby" + result[i].from;
      $(temp).css("background", "grey");
      //alert('hi');

    });
  });
}, 1000),

呼び出された関数、php の trackUnreadMsgs は次のとおりです。

public function trackUnreadMsgs() {
  $data['userData'] = $this - > session - > userdata('userData');
  $user_id = $data['userData'][0]['id'];

  $count_unread_msgs = $this - > data - > myquery("SELECT * FROM inbox WHERE `to`=".$user_id.
    " AND status='unread'");

  $count_unread_msgs = json_encode($count_unread_msgs);
  print_r($count_unread_msgs);
}

どうやらすべてがブラウザ (Chrome) で正常に動作しますが、これはコンソールが出力しているものです:

VM2800:1 Uncaught SyntaxError: Unexpected end of input(anonymous function) @ seth_custom.js:225j @ jquery-2.1.3.min.js:2k.fireWith @ jquery-2.1.3.min.js:2x @ jquery-2.1.3.min.js:4(anonymous function) @ jquery-2.1.3.min.js:4
jquery-2.1.3.min.js:4 GET http://localhost/innov/index.php/home/trackUnreadMsgs 500 (Internal Server Error)k.cors.a.crossDomain.send @ jquery-2.1.3.min.js:4n.extend.ajax @ jquery-2.1.3.min.js:4n.(anonymous function) @ jquery-2.1.3.min.js:4n.extend.getJSON @ jquery-2.1.3.min.js:4(anonymous function) @ seth_custom.js:203
jquery-2.1.3.min.js:4 GET http://localhost/innov/index.php/home/getAllUnreadMsgs 500 (Internal Server Error)k.cors.a.crossDomain.send @ jquery-2.1.3.min.js:4n.extend.ajax @ jquery-2.1.3.min.js:4n.(anonymous function) @ jquery-2.1.3.min.js:4n.extend.getJSON @ jquery-2.1.3.min.js:4(anonymous function) @ seth_custom.js:274
jquery-2.1.3.min.js:4 GET http://localhost/innov/index.php/home/trackUnreadMsgs 500 (Internal Server Error)k.cors.a.crossDomain.send @ jquery-2.1.3.min.js:4n.extend.ajax @ jquery-2.1.3.min.js:4n.(anonymous function) @ jquery-2.1.3.min.js:4n.extend.getJSON @ jquery-2.1.3.min.js:4(anonymous function) @ seth_custom.js:203
jquery-2.1.3.min.js:4 GET http://localhost/innov/index.php/home/trackUnreadMsgs 500 (Internal Server Error)k.cors.a.crossDomain.send @ jquery-2.1.3.min.js:4n.extend.ajax @ jquery-2.1.3.min.js:4n.(anonymous function) @ jquery-2.1.3.min.js:4n.extend.getJSON @ jquery-2.1.3.min.js:4(anonymous function) @ seth_custom.js:203
VM2805:1 Uncaught SyntaxError: Unexpected end of input

何が間違っているのか、なぜこのログを受け取るのか、どうすれば修正できるのかを知りたいです。これをローカルホストの Wamp サーバーで実行しています。

4

1 に答える 1