I have a page that is generated dynamically via the URL (GET Method). This dynamic page generates among a lot of other stuff the following line of HTML:
<input type='hidden' name='device' id='device' value='abcd' />
I am also loading several javascript functions, and I want one them to be able to read the initial value of 'device', however, it doesn't seem to be able to read the initial value on the intial page load. It will read it if the javascript function is fired again after the page load.
I am using the following code in my .js file
jQuery(document).ready(function(){
var device = jQuery('#device').val();
});
When debugging, on the intial page load device is simply set to 'undefined' Anyone have any ideas? Thanks.
Brian
$.ajax()or$.get()call occurring that's loading content, right? So it's loading asynchronously, and$.ready()is firing before theasync: trueloaded content loads. Have you tried settingasync: falseon the content loading?