 <p>Yeah, that's right. If you define a function inside a function, it will be private to that function. You need to create a global var</p> <pre><code>var recordjourney; $(document).ready(function(){ ... recordjourney = { var journey = ... etc </code></pre> <p>Although, of course, given that you are using JQuery I'd do</p> <pre><code>$(document).ready(function(){ ... $( 'button[name=record]' ).bind( function(){ //put your function here }) </code></pre> <p>and remove the ugly onclick="recordjourney from the button tags.</p>