locked
'jQuery' is undefined error in production site RRS feed

  • Question

  • User882828011 posted

    I developed a MVC4-Bootstrap3 site and it is working correctly when launched from visual studio but when the site is hosted in production environment (IIS7.5/Windows 2008 R2) it failed with 'jQuery is undefined' error message (see complete error message below). Am i missing something here? How did it work in visual studio to begin with?
    I hope to get some pointers from the experts in this forum.

    When view the source file in production here is the bottom portion and it seems to indicate that jquery is there:

        <script src="/Radnotes/bundles/jquery?v=AiaVZORFou3eDDIzQg9CLXeaTh_z2GTaiwT-jLTf0kE1"></script>
        <script src="/Radnotes/Scripts/Bootstrap?v=0sCzEKI91GvL5HwkTjbcxzyrs4M4EamTkTYBROrQnS41"></script>
        <script src="/Radnotes/bundles/jqueryval?v=K_2-68wDm3HfoAbtOMnO_yaExS_ZbfG1g7VPTWRYnsA1"></script>

    Here is my BundleConfig:

        public static void RegisterBundles(BundleCollection bundles)
            {
                bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                            "~/Scripts/jquery-{version}.js",
                            "~/Scripts/jquery-migrate-{version}.js"));
    
                bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                            "~/Scripts/jquery-ui-{version}.js"));
    
                bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                            "~/Scripts/jquery.unobtrusive*",
                            "~/Scripts/jquery.validate*"));
    
                // Use the development version of Modernizr to develop with and learn from. Then, when you're
                // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
                bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                            "~/Scripts/modernizr-*"));
    
                bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
    
                bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                            "~/Content/themes/base/jquery.ui.core.css",
                            "~/Content/themes/base/jquery.ui.resizable.css",
                            "~/Content/themes/base/jquery.ui.selectable.css",
                            "~/Content/themes/base/jquery.ui.accordion.css",
                            "~/Content/themes/base/jquery.ui.autocomplete.css",
                            "~/Content/themes/base/jquery.ui.button.css",
                            "~/Content/themes/base/jquery.ui.dialog.css",
                            "~/Content/themes/base/jquery.ui.slider.css",
                            "~/Content/themes/base/jquery.ui.tabs.css",
                            "~/Content/themes/base/jquery.ui.datepicker.css",
                            "~/Content/themes/base/jquery.ui.progressbar.css",
                            "~/Content/themes/base/jquery.ui.theme.css"));
    
                bundles.Add(new ScriptBundle("~/Scripts/Bootstrap").Include(
                            "~/Scripts/bootstrap.js",
                            "~/Scripts/bootstrap-datepicker.js",
                            "~/Scripts/moment.js",
                            "~/Scripts/bootstrap-datetimepicker.js"));
    
                bundles.Add(new StyleBundle("~/Content/Bootstrap").Include(
                           "~/Content/bootstrap.css",
                            "~/Content/bootstrap-datepicker.css"));
            }
    }

    Error:

    "Webpage error details
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
    Timestamp: Fri, 16 May 2014 14:17:57 UTC
    Message: Object doesn't support this property or method
    Line: 1
    Char: 38134
    Code: 0
    URI: http://localhost/Radnotes/bundles/jquery?v=AiaVZORFou3eDDIzQg9CLXeaTh_z2GTaiwT-jLTf0kE1
    Message: Bootstrap's JavaScript requires jQuery
    Line: 1
    Char: 31
    Code: 0
    URI: http://localhost/Radnotes/Scripts/Bootstrap?v=0sCzEKI91GvL5HwkTjbcxzyrs4M4EamTkTYBROrQnS41
    Message: 'jQuery' is undefined
    Line: 1
    Char: 1
    Code: 0
    URI: http://localhost/Radnotes/bundles/jqueryval?v=K_2-68wDm3HfoAbtOMnO_yaExS_ZbfG1g7VPTWRYnsA1
    Message: Object expected
    Line: 1
    Char: 1
    Code: 0
    URI: http://localhost/Radnotes/Scripts/MyScripts/homeviewscript.js"
    

    Thank you in advance. Great forum

    Friday, May 16, 2014 10:57 AM

Answers

  • User-166373564 posted

    Hi dvnandover,

    If I published the project in Debug mode to the server then it is working fine. The error occurred only when i published the project in release mode. So Is  this IIS issue? or Is it the publish tool of visual studio?

    Thanks for your feedback.

    Debug and Release are different configurations for building project. Generally use the Debug mode for debugging project, and the Release mode for the final build for end users. The Debug mode does not optimize the binary it produces (as optimizations can greatly complicate debugging), and generates additional data to aid debugging. The Release mode enables optimizations and generates less (or no) extra debug data.

    For this issue, we need look into it further.

    • Make sure that have this in deployed web.config file

            <compilation debug="false">

    • Choose "Clean Solution" under the Build options in Visual Studio, and check whether it helps you.

    Regards

    Angie

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 22, 2014 3:19 AM

All replies

  • User-166373564 posted

    Hi dvnandover,

    Welcome to asp.net forum.

    'jQuery' is undefined error in production site

    For this issue, you could use the Developer Tools (F12) within your browser to check the Console to see if any errors are occurring.

    At the same time there are some suggestions to deal with this error, please refer to the discussion below.

    'JQuery' is undefined 

    If you still has any concern, please let me know.

    Best regards

    Angie

    Sunday, May 18, 2014 11:13 PM
  • User882828011 posted

    When view using the Developer Tools (F12) There were no errors occured in the Console.

    As you can see from the Bundleconfig.cs file that Jquery was listed in first.

    Observation: If I published the project in Debug mode to the server then it is working fine. The error occurred only when i published the project in release mode. So Is  this IIS issue? or Is it the publish tool of visual studio?

    I am not sure how to get around the problem. It is frustrating.

    Any other suggesttions?

    Tuesday, May 20, 2014 9:56 AM
  • User-166373564 posted

    Hi dvnandover,

    If I published the project in Debug mode to the server then it is working fine. The error occurred only when i published the project in release mode. So Is  this IIS issue? or Is it the publish tool of visual studio?

    Thanks for your feedback.

    Debug and Release are different configurations for building project. Generally use the Debug mode for debugging project, and the Release mode for the final build for end users. The Debug mode does not optimize the binary it produces (as optimizations can greatly complicate debugging), and generates additional data to aid debugging. The Release mode enables optimizations and generates less (or no) extra debug data.

    For this issue, we need look into it further.

    • Make sure that have this in deployed web.config file

            <compilation debug="false">

    • Choose "Clean Solution" under the Build options in Visual Studio, and check whether it helps you.

    Regards

    Angie

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 22, 2014 3:19 AM