javascript - Object undefined on click -
i'm trying call member function of utilities object on button click. js file containing object loaded @ top of index.php
page:
<script type="text/javascript" src="js/utilities.js"></script> ...
and have defined button:
<button id="testajax" onclick="utilties.loadsavedgames()">load game</button>
when click, utilties not defined
error:
var utilities = { loadsavedgames : function () { console.log("clicked"); //returns utilties not defined },...
but i'm curious why if reload page, it's able call anon function. tells me utilties object being loaded @ page load:
var utilities = { dothis : (function() { console.log("utilities object loaded"); //runs fine })(),
so if object loaded @ top of index.php
page, why onclick
tell me object undefined?
in javascript setting utilities
, onclick referencing utilties
. missing i
.
Comments
Post a Comment