The issue is that the .load() function is asynchronous. When javascript executes that code, the .load() function is called, then immediately the next statement is executed; but the table doesn't exist yet.