Organizational Research By

Surprising Reserch Topic

how to insert jquery code uncaught referenceerror is not defined in view raz using -'jquery,asp.net,asp.net-mvc,asp.net-mvc-4'


how to insert jquery code uncaught referenceerror is not defined in view raz  using -'jquery,asp.net,asp.net-mvc,asp.net-mvc-4'

I have the following Asp.Net MVC 4 razor code at the end of the file.

....
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

<script type="text/javascript">
    $('#Address_State').val('MA');
</script>
////// End of file


However, it generated the following html code. And it raises error at the line $('#Address_State').val('MA');. The error message is Uncaught ReferenceError: $ is not defined. How to insert jQuery code in the razor file?

.....
<script type="text/javascript">
    $('#Address_State').val('MA'); // Uncaught ReferenceError: $ is not defined
</script>
            </section>
        </div>
        <footer>
            <div class="content-wrapper">
                <div class="float-left">
                    <p>&copy; 2013 - Paperspeed</p>
                </div>
            </div>
        </footer>

        <script src="/Scripts/jquery-1.9.1.js"></script>


    <script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>


    </body>
</html>


Update:

The following is the last four lines of _Layout.cshtml.

        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>

    
asked Sep 7, 2015 by rajesh
0 votes
49 views



Related Hot Questions



Government Jobs Opening


...