0
這有點傻,我在這裏找不到語法錯誤,但是chrome調試器告訴我他在第二行遇到了「意外的輸入結束」。有人有想法嗎?雖然通過了JSLInt,但輸入卻意外地結束了
$("head meta").each(function() {
var content = JSON.parse(this.content);
if (content.hasOwnProperty("bitpenny")) {
checkWhiteList(window.location.hostname, function (isIn, entry) {
if (!isIn) {
checkBlackList(window.location.hostname, function (isIn) {
if (!isIn) {
askUser(content, window.location.hostname);
}
});
}
});
}
});
好像錯誤加薪在'JSON.parse'函數中。你確定你的JSON是有效的嗎?你能提供'this.content'內容嗎? – antyrat
'head meta'中的哪些元素是你期望的JSON?如果即使其中一個不是,你也會得到這個錯誤。 [try..catch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try.catch)在這裏可能很有用。 – Blazemonger
你說得對。我考慮過這種可能性。 this.content是一個空字符串「」。我剛纔意識到這也是無效的json。 –