2016-04-14 36 views
3

SyntaxError: Unexpected end of inputを取得しています。コードは私にはうまく見えますが、何が欠けていますか?SyntaxError:予期しない入力の終了

function SaveGridster(jsonState) { 
     console.log('SaveGridster'); // I CAN SEE THIS IN CONSOLE 
     var msttou = { 
      "srno": "1", 
      "module": "ABT Meter Details", 
      "userid": "SYS", 
      "jsondata": "jsonState" 
     }; 


     $.ajax({ 
      type: "POST", 
      contentType: "application/json;charset=utf-8", 
      url: BaseAddress + "InstanceDataAPI", 
      dataType: "json", 
      data: JSON.stringify(msttou), 
      success: function (response) { 
       console.log('success'); 
      }, 
      error: function (xhr, status, error) { 
       console.log(error); 
       alert(xhr.responseText); 
      } 
     }); 
    } 

CONSOLE:

SyntaxError: Unexpected end of input 
    at Object.parse (native) 
    at jQuery.extend.parseJSON (http://localhost:2402/Scripts/jquery-1.10.2.js:564:23) 
    at ajaxConvert (http://localhost:2402/Scripts/jquery-1.10.2.js:8443:19) 
    at done (http://localhost:2402/Scripts/jquery-1.10.2.js:8199:15) 
    at XMLHttpRequest.callback (http://localhost:2402/Scripts/jquery-1.10.2.js:8792:8) 
+0

@guradio 3行 – Arbaaz

答えて

5

エラーがあなたの関数が取得されたAJAX応答内にあると思われます。 SyntaxErrorは、JSONパーサによって発行されます。 JSONの解析を無効にするには、dataTypeを 'text'に変換します。

+1

これはコメントではありませんか? – void

+1

おそらくまだコメントできません:( –

+0

SaveGridster関数が確実に実行されています。コンソールに最初のコンソールログメッセージが表示されるので、このコードの前に問題がある場合はこの機能が正しく実行されたとは思わないでしょうか? – Arbaaz

関連する問題