admin管理员组文章数量:1402839
I am getting SyntaxError: Unexpected end of input
. The code looks fine to me, what am i missing?
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)
I am getting SyntaxError: Unexpected end of input
. The code looks fine to me, what am i missing?
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)
Share
Improve this question
edited Apr 14, 2016 at 8:42
SamuraiJack
asked Apr 14, 2016 at 8:33
SamuraiJackSamuraiJack
5,56918 gold badges103 silver badges212 bronze badges
0
1 Answer
Reset to default 6It would appear the error lies within the AJAX response your function is getting. The SyntaxError is issued by the JSON parser. Convert the dataType to 'text' to disable JSON parsing.
本文标签: javascriptSyntaxError Unexpected end of inputStack Overflow
版权声明:本文标题:javascript - SyntaxError: Unexpected end of input - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744371820a2603065.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论