javascript - jquery function not working inside second document ready -
this question has answer here:
- what scope of variables in javascript? 23 answers
this strange issue confusing me completely. paste whole code make sure nothing missed.
echo " <script> $(function() { $('#biddingload').fadeout(500); function notice() { $('#auction_notice').show(); $('#auction_notice').css('background', 'rgba(0, 100, 0, 0.8)'); $('#auction_notice').html('<p>bid accepted!</p>'); settimeout(function() { $('#auction_notice').fadeout(); }, 1000); // <-- time in milliseconds console.log('loaded notice'); } // notice(); }); </script> ";
and right below that:
echo " <script> $(function() { notice(); }); </script> ";
this returns uncaught referenceerror: notice not defined
if run notice() in above (commented) part, works. how makes sense?
ok, let me rephrase question - how ($(function() {) different scope? right code call function afterwards?
this jshint, tool helps detect errors , potential // problems in javascript code.
visit http://jshint.com/
Comments
Post a Comment