javascript - set var equal to data returned from a function
<pre><code>var ipAddress="unknown";
$.getJSON('http://jsonip.appspot.com/?callback=?',
function(data){
ipAddress=data.ip;});


document.getElementById('callbackForm').elements["callback_form.ipAddress"].value = ipAddress;
</code></pre>

<p>This javascript code sets the var ipAddress equal to 'unknown', then executes a jquery function that sets the value of ipAddress to the user's ip.  Then I attempt to set a form element equal to the value of ipAddress.</p>

<p>This is not working.  The form element is being set to 'unknown'.  I'm not sure if this is a scoping problem?  Any advice appreciated.</p>
