I am trying to parse my URL in document.ready() so that I can get the id of the current page and dynamically populate the page with results from an AJAX call. The problem I am running into is due to the fact that I think that 'document.URL' references the previous page until 'document.ready()' has fully executed.
How do I get around this? I have researched document.load(), and auto-refreshing the page once, but I cannot seem to get this to work. I have been working on this since yesterday.
Here is my code:
$( document ).ready( function(){
var id = document.URL.substring(document.URL.lastIndexOf('?')+4);
if(!loadObject.executed) {
loadObject(id);
loadObject.executed = true;
} else {
$('#page-full').on('pagecreate', loadObject(id));
}
});
Try to use document.location.href instead of document.URL.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With