我得到錯誤:SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data
錯誤語法錯誤:JSON.parse:後JSON數據意外非空白字符
我的代碼:
<script>
$(document).ready(function() {
$('.edit1').on('change', function() {
arr = $(this).attr('class').split(" ");
var clientid = document.getElementById("client").value;
account_id = document.getElementById("account_id").value;
$(this).parent().next().find('input:checkbox').attr("checked", true);
$.ajax({
type: "POST",
url: "clientnetworkpricelist/routestatusupdate.php",
data: "value=" + $(this).val() + "&rowid=" + arr[2] + "&field=" + arr[1] + "&clientid=" + clientid + "&account_id=" + account_id,
success: function (result) {
data = jQuery.parseJSON(result); //added line
var obj = data;
$('#CPH_GridView1_Status' + arr[2]).empty();
$('#CPH_GridView1_Status' + arr[2]).append(data.status);
$('.ajax').html($(this).val());
$('.ajax').removeClass('ajax');
}
});
}
);
});
</script>
而且JSON輸出:
{"status":"<img src=\"image\/Equalf.png\" \/>","seleniumrouteupdate":"1","routeupdate":"100"}{"status":"<img src=\"image\/Equalf.png\" \/>","seleniumrouteupdate":"1","routeupdate":"100"}{"status":"<img src=\"image\/Equalf.png\" \/>","seleniumrouteupdate":"1","routeupdate":"100"}
您是否粘貼了4次JSON輸出? – Satpal
就像錯誤所說 - 你的JSON是無效的。你不能在那兒(他們有什麼?) –
你檢查過JSONLint嗎?你的JSON無效。 http://jsonlint.com/ – Utkanos