javascript - jquery function not working inside second document ready -


this question has answer here:

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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -