JavaScript runtime error: '$' is undefined
If you’re developing an MVC4 app and run into this error, you probably haven’t placed your scripts in the Script section.
Looking at the _Layout.cshtml file, you’ll see one of the last lines is
@RenderSection("scripts", required: false)
which will render a section titled scripts. The following is a sample:
@section Scripts { <script type="text/javascript"> $(function () { alert("JQuery loaded and working!!"); }); </script> }
Here’s a link to the Gu man’s discussion of sections.
Cost me about 3 hours. Hope it saves you a few!!!
Comments