jquery使用json_encode从控制器获取数据

ajax function

<script type="text/javascript">
    var timeOutID =0;
    var checkScores =  function () {
        $.ajax({
            url: 'http://127.0.0.1/ProgVsProg/main/countScoreCh',
            success: function(response) {
                if(response == false){
                    timeOutID = setTimeout(checkScores, 3000);
                } else {
                    jsn = JSON.parse(response);
                    score= jsn.scoreCH;
                    $('#progressbar').progressbar({
                        value: score
                    });
                    clearTimeout(timeOutID);
                }
            }
        });
    }

    timeOutID = setTimeout(checkScores,1000);
</script>

Controller

public function countScoreCh(){
    $id = $this->session->userdata('userID');
    $data['getScore'] = $this->lawmodel->battleUserID($id);
    foreach($data['getScore'] as $row){
        $scoreCH = $row->challengerScore;
        echo json_encode(array('scoreCH' => $scoreCH));
    }
}

Im having a problem..im using a progress bar..my idea is making the progress bar like a Hit Point/Health bar..but it seems that when i put the $('#progressbar').progressbar it will not get the value from jsn.scoreCH..jst disregards the response == false it still working i tried using console log..But when i put this code..it will not be read and display the output..

 $('#progressbar').progressbar({
     value: score
 });

You can omit JSON.parse(response). Just use dataType: 'json'

$.ajax({
        url: "http://127.0.0.1/ProgVsProg/main/countScoreCh",
        dataType: 'json'
        success: function(response) {
            if(response.scoreCH == undefined){
                timeOutID = setTimeout(checkScores, 3000);
            } else {
                $('#progressbar').progressbar({
                    value: response.scoreCH
                });
                clearTimeout(timeOutID);
            }
        }
    });