最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - TypeError: $(...).bootstrapValidator is not a function , it does load the ContactUs.js file, but it's not a

programmeradmin1浏览0评论

As the Code is given and it is not able to find the function. I have tried several changes but still get the Error the sequence is also correct. The head part is at the top script and the other environment development is at the bottom of the code between the <body> section.

<head>       
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>About Us-Azure Solutionz</title>

        <environment names="Development">
            <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
            <link rel="stylesheet" href="//cdnjs.cloudflare/ajax/libs/jquery.bootstrapvalidator/0.5.3/css/boots‌​trapValidator.css"/>

            <link rel="stylesheet" href="css/ContactUs.css" />
            <link rel="stylesheet" href="~/css/site.css" />
             <link rel="stylesheet" href="css/NavbarButton.css"/>
            <link rel="stylesheet"  href="css/AboutUs.css"/>

              <link rel="stylesheet" href="css/Footer.css"/>
        </environment>
        <environment names="Staging,Production">
            <link rel="stylesheet" href=".3.5/css/bootstrap.min.css"
                  asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
                  asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
            <link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true"/>
        </environment>

    </head>
<environment names="Development">
            <script src="~/lib/jquery/dist/jquery.js"></script>
            <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
            <script src="~/js/site.js" asp-append-version="true"></script>
        </environment>
        <environment names="Staging,Production">
            <script src=".1.4.min.js"
                    asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
                    asp-fallback-test="window.jQuery">
            </script>
            <script type="text/javascript" src="//cdnjs.cloudflare/ajax/libs/jquery/2.1.0/jquery.js"></script>
            <script src=".3.5/bootstrap.min.js"
                    asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
                    asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal">
            </script>
            <script type="text/javascript" src="//cdnjs.cloudflare/ajax/libs/jquery.bootstrapvalidator/0.5.3/js/bootstr‌​apValidator.js"></script>
            <script src="js/ContactUs.js" type="text/javascript"></script>
            <script src="~/js/site.min.js" asp-append-version="true"></script>
        </environment>

As the Code is given and it is not able to find the function. I have tried several changes but still get the Error the sequence is also correct. The head part is at the top script and the other environment development is at the bottom of the code between the <body> section.

<head>       
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>About Us-Azure Solutionz</title>

        <environment names="Development">
            <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
            <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.3/css/boots‌​trapValidator.css"/>

            <link rel="stylesheet" href="css/ContactUs.css" />
            <link rel="stylesheet" href="~/css/site.css" />
             <link rel="stylesheet" href="css/NavbarButton.css"/>
            <link rel="stylesheet"  href="css/AboutUs.css"/>

              <link rel="stylesheet" href="css/Footer.css"/>
        </environment>
        <environment names="Staging,Production">
            <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/css/bootstrap.min.css"
                  asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
                  asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
            <link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true"/>
        </environment>

    </head>
<environment names="Development">
            <script src="~/lib/jquery/dist/jquery.js"></script>
            <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
            <script src="~/js/site.js" asp-append-version="true"></script>
        </environment>
        <environment names="Staging,Production">
            <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"
                    asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
                    asp-fallback-test="window.jQuery">
            </script>
            <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.js"></script>
            <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/bootstrap.min.js"
                    asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
                    asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal">
            </script>
            <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.3/js/bootstr‌​apValidator.js"></script>
            <script src="js/ContactUs.js" type="text/javascript"></script>
            <script src="~/js/site.min.js" asp-append-version="true"></script>
        </environment>
Share Improve this question edited Mar 1, 2016 at 16:10 Mr Lister 46.6k15 gold badges113 silver badges155 bronze badges asked Feb 27, 2016 at 6:10 ShahzebShahzeb 951 gold badge1 silver badge8 bronze badges 0
Add a comment  | 

3 Answers 3

Reset to default 11

your url results in 404 error :

https://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.3/js/bootstr‌​apValidator.js

try this link :

https://cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.5.3/js/bootstrapValidator.js

From here thanks shehary

TypeError: $(…).... is not a function

is a common error where

  1. jQuery library not included at all in the document

  2. Specific JS library (in this case bootstrapvalidator.js) placed above jQuery library or not included at all in the document.

  3. When following the most common practice to put all JS libraries in footer and then place custom scripts somewhere inside the page above all JS libraries and those custom script(s) not $(document).ready(function(){ });

Best and most common practice using JS libraries is in following order

  1. JQuery lib (Always comes first)

  2. Framework lib (e.g bootstrap, foundation etc)

  3. Any other additional JS libraries

Custom script lib (Put all custom scripts here and make sure they are DOM ready and this file always placed as last file)

Try to place the CSS and JS in following order in section

<head>
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css"/>
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.3/css/bootstrapValidator.css"/>
    <!---- AnyOther custom stylesheets ---->
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.js"></script>
    <script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.3/js/bootstrapValidator.js"></script>
    <!---- Any

Add this:

    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.3/js/bootstrapValidator.min.js"> </script>

after your jquery library and framework librery (bootstrap, etc)

so you will have something like this:

 <script src="Scripts/jquery-1.9.1.js"></script>
    <script src="Scripts/jquery-1.9.1.min.js"></script>
    <script src="Scripts/bootstrap.min.js"></script>
    <script src="Scripts/bootstrap.js"></script>
<%-- here you may add another scripts you have...  --%>
    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.3/js/bootstrapValidator.min.js"> </script>

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论