我在JavaScript中有一個基本功能,只需使用一些預設值並通過使用預製功能將它們放到屏幕上。當我斷開第一行時,頁面加載正常,但是一旦我移除該斷點,就沒有設置任何信息。並且頁面是空白的。JavaScript僅適用於在瀏覽器調試器中設置的斷點
this.QuizSelection = function() {
// Fill the ID's with the right info
app.SetBackground('head', this.HeroImage);
console.log('1 ' + this.HeroImage);
app.LoadInnerHTML('breadcrumbs', 'Home/' + this.Title);
app.LoadInnerHTML('quizSelectionTitle',this.Title);
console.log('2 ' + this.Title);
app.LoadInnerHTML('quizSelectionIntro',this.Introduction);
console.log('3 ' + this.Introduction);
// Show the Quiz Selection and Heading
app.ShowSection('head');
app.ShowSection('quizSelection');
console.log('Quiz Selection');
}.bind(this);
即(的setBackground和LoadInnerHTML)內的函數是改變內HTML和設置背景圖像只是小一個行功能。
// Change Inner HTML
this.LoadInnerHTML = function (id, html) {
var d = document.getElementById(id);
d.innerHTML = html;
}
// Set Background Image
this.SetBackground = function (id, image) {
document.getElementById(id).style.backgroundImage = 'url(image)';
}
我不明白爲什麼它不會工作,當斷點不開。顯然,它的工作,因爲一切都很好用的斷點,但是當它關閉的結果我得到輸出到控制檯:
1
2
3 undefined
Quiz Selection
這不是你如何顯示數據,這是你如何得到它的第一個地方。 「this.Title」,「this.Introduction」等來自哪裏? – JJJ
來自JSON文件 - 當我在調試器 –
Ajax調用中觀察變量時,它們加載得很好嗎?最佳猜測:[如何返回來自異步調用的響應?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – JJJ