2017-05-23 59 views
0

我使用dolphin社交網絡腳本,我有多個語言文件與json和當我通過其他語言,然後如果我點擊主頁或另一個鏈接然後谷歌瀏覽器給了我這個錯誤行..我讀了相同的標題的stackoverflow,但我不能失業。我如何解決'未捕獲的SyntaxError:意外的JSON輸入結束'錯誤

腳註:我的腳本是php,我用json_encode();utf8_encode();但沒有任何反應,因爲同時我有土耳其角色問題。

footnote2:我改變MySQL字符設置得又一次沒有happend

enter image description here

控制檯給了我這個錯誤

feed:1 Uncaught SyntaxError: Unexpected end of JSON input 
    at Function.parse [as parseJSON] (<anonymous>) 
    at Object.success (functions.js:2102) 
    at i (jquery.js:2) 
    at Object.fireWith [as resolveWith] (jquery.js:2) 
    at A (jquery.js:4) 
    at XMLHttpRequest.<anonymous> (jquery.js:4) 

和我functions.js:2102線

// Request the page 
 
$.ajax({ 
 
    url: pageurl, 
 
    type: type, 
 
    data: parameters, 
 
    success: function(data) { 
 
    var result = jQuery.parseJSON(data); 
 
    // Show the content 
 
    $('#content').html(result.content); 
 
    // Stop the loading bar 
 
    stopLoadingBar(); 
 
    // Set the new title tag 
 
    document.title = result.title; 
 
    // Scroll the document at the top of the page 
 
    $(document).scrollTop(0); 
 
    load_modes(); 
 
    // Reload functions 
 
    reload(); 
 
    } 
 
});

此行

function liveLoad(pageurl, type, parameters) { 
 
\t // page url = request url 
 
\t // type = 1: POST; 0: GET; 
 
\t // parameters: serialized params 
 
\t cleanOldFid(); 
 
\t startLoadingBar(); 
 
\t 
 
\t if(type == 1) { 
 
\t \t var type = "POST"; 
 
\t } else { 
 
\t \t var type = "GET"; 
 
\t } 
 

 
\t // Request the page 
 
\t $.ajax({url: pageurl, type: type, data: parameters, success: function(data) { 
 
\t \t var result = jQuery.parseJSON(data); 
 
\t \t // Show the content 
 
\t \t $('#content').html(result.content); 
 
\t \t // Stop the loading bar 
 
\t \t stopLoadingBar(); 
 
\t \t // Set the new title tag 
 
\t \t document.title = result.title; 
 
\t \t // Scroll the document at the top of the page 
 
\t \t $(document).scrollTop(0); 
 
\t \t load_modes(); 
 
\t \t // Reload functions 
 
\t \t reload(); 
 
\t }}); 
 
\t 
 
\t // Store the url to the last page accessed 
 
\t if(pageurl != window.location) { 
 
\t \t window.history.pushState({path:pageurl}, '', pageurl); \t 
 
\t } 
 
\t return false; 
 
}

回答

0

你能否證實,在你成功函數返回的數據參數的最終功能是有效的JSON?看起來像jQuery.parseJSON()函數拋出的錯誤。

您應該在成功函數頂部添加一個console.log(data),以通過聯機JSON驗證程序(請參閱jsonlint)檢查和運行內容。

相關問題