Tags: ASP.NET MVC, jQuery,
When a ASP.NET MVC project is created in Visual Studio 2017, Jquery is built in. But when you try to use jQuery in the index.cshtml file, you will get the following error:
#img1#
The wield thing here is that Visual studio's template imports jquery script after @RenderBody(). The code you write in index.cshtml is rendered by @RenderBody(). But as this happen before jQuery is imported, you get the $ is not defined error.
To fix this issue, you will have to move this code into the head section.
#img2#
没有评论:
发表评论