简体   繁体   English

IIS 7.5网站上的asp.net mvc3网站未加载jquery

[英]asp.net mvc3 website on IIS 7.5 website not loading jquery

Newbie here on jQuery struggling with some deployment essentials: jQuery的新手在努力解决一些部署要点:

Working with the default asp.net mvc3 template that comes with VS2010, I tried to include the jquery ui selectable widget. 使用VS2010随附的默认asp.net mvc3模板,我尝试包括jquery ui可选小部件。 In the header section of _Layout.cshtml, I have the following possibilities: 在_Layout.cshtml的标题部分中,我有以下可能性:

    @* <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>*@
   @* <script src="@Url.Content("http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.min.js")" type="text/javascript"></script>*@
    @*    <script src="@Url.Content("http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.11/jquery-ui.min.js")" type="text/javascript"></script>*@
    <script src="@Url.Content("https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js")" type="text/javascript"></script>

I cannot get any of these scripts to load, as widget does not display on the site within IIS. 我无法加载这些脚本中的任何一个,因为窗口小部件未显示在IIS中的站点上。 Within Visual Studio, I can see jQuery content. 在Visual Studio中,我可以看到jQuery内容。

I have looked through all IIS settings for the site but nothing appears to be javascript related. 我已经查看了该站点的所有IIS设置,但是似乎没有与javascript相关的内容。 I read the following related posts: 我阅读了以下相关文章:

which does not seem to be the case here as I have tried absolute paths with the correct Url.Content syntax. 这似乎不是这里的情况,因为我尝试了使用正确的Url.Content语法的绝对路径。 Probably missing something but what could it be? 可能丢失了一些东西,但是可能是什么?

EDIT 1 Changed load minified version of jQuery from google to see if this is the problem. 编辑1从Google更改了jQuery的最小加载版本,看是否是问题所在。

When you are referencing items on another domain you don't need the HTML Helper @Url.Content() Try just using the URL without the helper. 当您引用另一个域上的项目时,不需要HTML帮助程序@Url.Content()尝试仅使用不带帮助程序的URL。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" 
        type="text/javascript"></script>

Also if you can post a link to the site or the raw HTML that is rendered in the browser we can determine quickly what is happening. 同样,如果您可以发布网站链接或浏览器中呈现的原始HTML,我们也可以快速确定正在发生的事情。

Thanks for all the response. 感谢您的所有回复。 After further digging, it turns out that this is not a jQuery loading issue after all. 经过进一步的挖掘,结果证明这毕竟不是jQuery加载问题。 Scripts are being loaded correctly. 脚本已正确加载。 If I hardcode the children of the jQuery selectable like so 如果我像这样对jQuery可选子项进行硬编码

<ol id="selectable">
                <li class="ui-state-default">test</li>
            </ol>

it loads under IIS. 它在IIS下加载。

However, jQuery selectable is given children dynamically in the following ajax snippet: 但是,在以下ajax代码段中,为jQuery selectable动态提供了子级:

  function GetBusRoutes(parameters) {
         $.ajax({
                type: "POST", 
                 url: "/home/GetAvailableRoutes",  
                contentType: "application/json; charset=utf-8", 
                dataType: "json", 
                failure: function (msg) {
                    alert(msg);
                }, 
                success: function (msg) {
                    var selectable = $('#selectable');
                    $.each(msg, function(i, route) {
                        selectable.append($('<li/>', { "class": "ui-state-default", text: route.Name}));
                    });
                } 

         });
     }

and the HTTP GET request if failing with a 404 as it is trying to resolve the url to http://localhost:80/home/GetAvailableRoutes instead of invoking my controller action, which is what happens when site runs under Visual Studio. 和HTTP GET请求(如果失败),因为404尝试将URL解析为http:// localhost:80 / home / GetAvailableRoutes而不是调用我的控制器操作,这是在Visual Studio上运行网站时发生的情况。 Will post another question on this if I cannot figure out correct syntax to pass to the ajax url. 如果我找不到正确的语法来传递给ajax网址,将会对此发表另一个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM