0

I have included jquery and bootstrap.min.js file in my footer section or it means i have my all script tag at the bottom of the code. But when i am loading my page the browser console throw an error says : Uncaught Error: Bootstrap's JavaScript requires jQuery. I am including these files locally like below:-

</footer>
<script src="http://127.0.0.1/ems_ci/assets/js/jquery.js" type="text/javascript"></script>
<script src="http://127.0.0.1/ems_ci/assets/js/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
6
  • why put it footer?why not in header? Commented Apr 23, 2016 at 6:30
  • are you sure the path http://127.0.0.1/ems_ci/assets/js/jquery.js is valid Commented Apr 23, 2016 at 6:32
  • what does pasting this in the browser console show: if (window.jQuery) { console.log('jQuery is loaded'); } else { console.log('jQuery is not loaded'); } Commented Apr 23, 2016 at 6:47
  • try to give a better link to your js file. The link may be broken, that's a common issue that you get. Just try to look into it thank you. Commented Apr 23, 2016 at 6:48
  • I have both jquery/bootstrap file in order like -- <script src="<?php echo base_url(); ?>assets/js/jquery.js" type="text/javascript"></script> -- <script src="<?php echo base_url(); ?>assets/js/bootstrap.min.js" type="text/javascript"></script> </body> </html> Commented Apr 23, 2016 at 6:54

2 Answers 2

1

It's uncommon to use localhost or 127.0.0.1 for a file path. Use relative path instead.

Regarding script position: you can leave them in the footer, that will speed up page loading, but make sure any JavaScript code you execute is AFTER jquery/bootstrap in the dom. And don't forget to wrap your code inside a document ready jquery function

Sign up to request clarification or add additional context in comments.

2 Comments

@Enrico- I have my files like -- <script src="<?php echo base_url(); ?>assets/js/jquery.js" type="text/javascript"></script> <script src="<?php echo base_url(); ?>assets/js/bootstrap.min.js" type="text/javascript"></script> </body> </html>
Are you doing that in purpose? Also, i suppose that will not work, Because 127.0.0.1 will look for jquery on the client machine, not the server
0

To begin, you must change the location of the tag 'script' into the tag 'head'. after this, you must change the location of your javascript scripts to your project directory. Finally, you change the value of the 'src' attribute to: Ex:

  • src="../js/jquery.js"
  • src="../js/bootstrap.min.js"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.