firebug でこの JavaScript コード (scoreboard.js) をステップ実行すると、アラートで正常に動作します。firebug に改行を入れずに普通に実行したところ、「favs is null」というメッセージが表示されました (アラートはありません)。
var favs = $.getJSON("favs.json");
favs = $.parseJSON(favs.responseText);
favs = favs.myTeams;
for (i=0; i<favs.length; i++){
alert(favs[i].text);
}
JSON (favs.json)
{"myTeams":[{"sport":10,"id":10,"abbrev":"NYY","isFav":false,"text":"New York Yankees","sw_abbrev":"nyy"},{"sport":28,"id":19,"abbrev":"nyg","isFav":false,"text":"New York Giants","sw_abbrev":"nyg"},{"sport":46,"id":18,"abbrev":"NY","isFav":false,"text":"New York Knicks","sw_abbrev":"nyk"},{"sport":90,"id":11,"abbrev":"NJ","isFav":false,"text":"New Jersey Devils","sw_abbrev":"njd"},{"sport":41,"id":2507,"abbrev":"PROV","isFav":false,"text":"Providence Friars"},{"sport":46,"id":17,"abbrev":"NJ","isFav":false,"text":"New Jersey Nets","sw_abbrev":"njn"},{"sport":600,"id":363,"abbrev":"Blues","isFav":false,"text":"Chelsea","sw_abbrev":"ENG.CHELSEA","isNational":false}]}
HTML
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="scoreboard.js"></script>
</head>
<body>
Test
</body>
ここで何が起こっているのか分かりますか?