2016-05-02 33 views
0

、ここでのコードは500内部サーバーエラー、アヤックス、のsetInterval

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); 
} 

どうやらすべてがブラウザ(クローム)に罰金動作しますが、これはコンソールが印刷は何かということです:

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 

私が知りたい、私が間違って何をやっている、なぜ私はこれを受け付けておりますログ&これを修正する方法。私はlocalhost Wampサーバーでこれを実行しています。

+1

*「500 Internal Server Error」* - ログを確認してください。 –

+0

'}、1000)、' - ここの最後の小さな男はどう? – Marcus

+0

*このタグは使用しないでください。あなたの質問を*あなたがそれを追加したときに読んだタグの説明に従って分類することは無意味です。 – Adriaan

答えて

0

AJAXリクエストで間違ったルートを設定しました。 正しいパスである

$ .getJSON( '/ INNOV/index.phpを/ホーム/ trackUnreadMsgs'、関数(結果){...})。

+0

私はcodeigniterを使用していますが、PHPのコントローラにアクセスするためのプロトコルはcontrollerName/functionNameです。 –

+0

ルートパスが間違っているため、システムがAjax呼び出しを行うホストをcodeigniterまたはハードコードで設定して編集する必要があります –