Reputation: 18857
Newbie here on jQuery struggling with some deployment essentials:
Working with the default asp.net mvc3 template that comes with VS2010, I tried to include the jquery ui selectable widget. In the header section of _Layout.cshtml, I have the following possibilities:
@* <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. Within Visual Studio, I can see jQuery content.
I have looked through all IIS settings for the site but nothing appears to be javascript related. 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. 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.
Upvotes: 0
Views: 1603
Reputation: 18857
Thanks for all the response. After further digging, it turns out that this is not a jQuery loading issue after all. Scripts are being loaded correctly. If I hardcode the children of the jQuery selectable like so
<ol id="selectable">
<li class="ui-state-default">test</li>
</ol>
it loads under IIS.
However, jQuery selectable is given children dynamically in the following ajax snippet:
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. Will post another question on this if I cannot figure out correct syntax to pass to the ajax url.
Upvotes: 0
Reputation: 11767
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.
<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.
Upvotes: 2