I want to get a string from a php script, and parse it to a javascript array. but got the error : SyntaxError: JSON.parse: unexpected character for the line :JSON.parse(msg);
I searched a lot , couldn't figure out where is my problem, please help check for me. Thanks.
PHP side :
header("application/json; charset=utf-8");
$sum = array(1,2,3,4,5);
echo json_encode($sum);
Javascript :
$.ajax({
    type: "POST",
    url: "save.php",
    contentType: "application/json; charset=utf-8",
    data: price,
    success: function (msg) {
        var i = 0;
        console.log(msg);
        var sum = new Array();
        sum = JSON.parse(msg);
        $('input.hj').each(function () {
            if (sum[i] > 0) {
                $(this).val(sum[i]);
            }
            i++;
        });
    }
});


console.log(msg);. Is it an object or a string? If it is an object, you don't have to and cannot parse it.console.log(typeof msg);showstringas well?