JS コンソールに「ErrorType: SyntaxError, Message: Unexpected identifier ,FuncName: Request UserCallback」というエラーが表示されます。ここで答えを探したところ、その人の構文がずさんなだけの質問が見つかりました。私は自分のコードを JSLint に通して、同じ問題があるかどうかを確認しましたが、そうではなかったことがわかりました。
このコードは拡張スコープで実行されています。
function loadTool()
{
$('body').prepend(appAPI.resources.get('html/base.html'));
appAPI.resources.includeCSS('css/mycss.css');
$('#tool-logo').attr('src', appAPI.resources.get('img/logo-white.png'));
$('#tool-nav-btn').attr('src', appAPI.resources.get('img/btn-menu.png'));
appAPI.request.get({
url: 'https://url',
onSuccess: function(response) {
var json = appAPI.JSON.parse(response);
if (json.messages)
{
console.log("User is logged in.");
return getColl();
}
return $('#tool-content').html(appAPI.resources.get('html/login.html'));
},
onFailure: function(httpCode) {
return console.log("Failure. HTTP Code: " + httpCode);
}
});
}
function getColl()
{
appAPI.request.get({
url: 'https://url',
onSuccess: function(response) {
console.log("Collections JSON fetched successfully!");
var jsonColl = appAPI.JSON.parse(response);
return $('#tool-body').html(appAPI.resources.parseTemplate('html/collections.html', {collections: jsonColl}));
},
onFailure: function(httpCode) {
return console.log("Failed to GET Collections: " + httpCode);
}
});
}
レポートは私のコードの行番号を示していませんが、それが参照している割り当ては console.log("Collections JSON fetched successfully!"); の後であると思います。発火するからです。私は途方に暮れています。