0

I am using MVC framework. jQuery is loaded in the layout page but when I try to run script on pages that are using the layout page, the script is not running and gives this error: Uncaught ReferenceError: $ is not defined I am running the following script to debug

    $(document).ready(function () {
        if (jQuery) {
        // jQuery is loaded
          alert("Yeah!");
          alert($().jquery);
        } else {
        // jQuery is not loaded
          alert("Doesn't Work");
        }
    });

If I put this script it will run and if I put it in a page that uses the layout page it will not run. I tried to load jQuery locally and from CDN and both method has the same problem.

Gautham
  • 150
  • 1
  • 2
  • 13
HaithamK
  • 11
  • 1
  • Do you mind sharing your code on how your loading your jQuery js file – Gautham Nov 21 '20 at 06:23
  • 3
    Does this answer your question? [JQuery - $ is not defined](https://stackoverflow.com/questions/2194992/jquery-is-not-defined) – Gautham Nov 21 '20 at 06:39
  • Thanks for the link. I found a tip there about using @section Scripts. I used it and the problem is solved – HaithamK Nov 21 '20 at 06:51
  • 2
    Glad to help. Next time make sure it is not a question that is asked here in stack overflow . Helps to avoid redundancy. Also read [how to ask](https://stackoverflow.com/help/how-to-ask) before asking a question. – Gautham Nov 21 '20 at 06:54

0 Answers0