2013-04-18 46 views
1

我有4名玩家在JSON和$ .getJSON JavaScript工作得很好,然後我在JSON添加16個更多的球員後,表中的球員名單消失。我做錯了什麼?表中的撲克玩家列表消失了使用JSON

的Javascript

$(document).ready(function() { 
    $.getJSON("js/dataPokerPlayers.json", function(data) { 
     $.each(data, function(i, data){ 
      $(".tableData tbody").append("<tr><td class=\"centertext\">" + data.rank + "</td><td>" + data.name + "</td><td class=\"centertext\">" + data.earnings + "</td><td class=\"centertext\">" + data.points + "</td><td class=\"centertext\">" + data.totalearnings + "</td></tr>"); 
     }); 
    }); 
}); 

JSON - http://www.elitedeafpoker.com/dev/js/dataPokerPlayers.json

我試圖消除所有16名球員在JSON並留下4他們在那裏之前,他們正好表明罰款表 - 怎麼回事?我只需複製/粘貼JSON行以獲取玩家的新數據。

回答

1

解析JSON文檔時發生錯誤。文件可能不完整。

看起來像是缺少逗號。

嘗試使用this tool來驗證您的JSON文件。

+0

我收藏了它 - 謝謝! – Christian

3

您的JSON缺少一些逗號,即正好位於第四行之後。

[ 
    {"rank": "1", "name": "Chad Demon", "earnings": "$9,600", "points": "345", "totalearnings": "$72,500"}, 
    {"rank": "2", "name": "Clay Chaman", "earnings": "$8,600", "points": "245", "totalearnings": "$42,500"}, 
    {"rank": "3", "name": "Christian Luneborg", "earnings": "$7,800", "points": "145", "totalearnings": "$52,500"}, 
    {"rank": "4", "name": "Steve Drills", "earnings": "$6,500", "points": "45", "totalearnings": "$2,250"}, 
    {"rank": "5", "name": "Paul Sims", "earnings": "$5,600", "points": "345", "totalearnings": "$11,500"}, 
    {"rank": "6", "name": "Melissa Suzy", "earnings": "$4,600", "points": "245", "totalearnings": "$24,500"}, 
    {"rank": "7", "name": "Philiip Samon", "earnings": "$3,800", "points": "145", "totalearnings": "$2,500"}, 
    {"rank": "8", "name": "Steve Glass", "earnings": "$2,500", "points": "45", "totalearnings": "$2,000"}, 
    {"rank": "9", "name": "Sven Zebers", "earnings": "$1,600", "points": "345", "totalearnings": "$12,500"}, 
    {"rank": "10", "name": "Chris Spabling", "earnings": "$1,000", "points": "245", "totalearnings": "$22,500"}, 
    {"rank": "11", "name": "John Cozz", "earnings": "$500", "points": "145", "totalearnings": "$52,500"}, 
    {"rank": "12", "name": "Karlan Suller", "earnings": "$485", "points": "45", "totalearnings": "$2,500"}, 
    {"rank": "13", "name": "Kim Uzi", "earnings": "$350", "points": "345", "totalearnings": "$12,500"}, 
    {"rank": "14", "name": "Eric Borg", "earnings": "$325", "points": "245", "totalearnings": "$21,500"}, 
    {"rank": "15", "name": "Jasper Russo", "earnings": "$250", "points": "145", "totalearnings": "$52,500"}, 
    {"rank": "16", "name": "Bruce Willis", "earnings": "$225", "points": "45", "totalearnings": "$42,500"}, 
    {"rank": "17", "name": "Tim Burdlen", "earnings": "$200", "points": "345", "totalearnings": "$82,500"}, 
    {"rank": "18", "name": "Matt Erickson", "earnings": "$175", "points": "245", "totalearnings": "$22,500"}, 
    {"rank": "19", "name": "Matt Sears", "earnings": "$125", "points": "145", "totalearnings": "$62,500"}, 
    {"rank": "20", "name": "Dong Smith", "earnings": "$100", "points": "45", "totalearnings": "$32,500"} 
] 
+0

是的,這是我 - 它現在工作 - 謝謝你! – Christian

+0

標記爲答案? :) –