
I'm trying to call fxn function outside $(document).ready(), but I can't get it working. It returns ReferenceError: fxn is not defined.. anything I missed?
Because of the way jQuery works. This error is predictable.
What is happening, is the declaration of fxn is waiting until the document is actually ready. Where the call to this method is not. So, by attempting this you are in essence trying to call a function that doesn't yet exist.
As per: http://learn.jquery.com/using-jquery-core/document-ready/
A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside
$( document ).ready()will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Code included inside$( window ).load(function() { ... })will run once the entire page (images or iframes), not just the DOM, is ready.
document.ready()... otherwisefunction callline will be executed beforefunction definitionor every thing outside ofdocument.ready().