开发者

Ajax loade View can't load javascript

开发者 https://www.devze.com 2023-04-11 07:18 出处:网络
I\'m trying to load some views using ajax, and they开发者_Go百科 are loading OK. But the scripts they have, are not being loaded on the specific section. Why?

I'm trying to load some views using ajax, and they开发者_Go百科 are loading OK.

But the scripts they have, are not being loaded on the specific section. Why?

View code:

@model INTREPWEB.Models.BoardingViewModel
@{
    ViewBag.Title = "Create";

    if (IsAjax)
    {
        Layout = null;
    }
}
@using (Html.BeginForm())
{
    @Html.Partial("CreateEdit")
}
@section Scripts{
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery-ui-timepicker-addon.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/intrep-datetime.js")" type="text/javascript"></script>
}


Because you are loading just a content like a plain text. Try to parse loaded content and invoke all your script references with $.getScript().

EDIT

As an alternative can be used:

$.ajax({
  url: url,
  dataType: 'script'
});
0

精彩评论

暂无评论...
验证码 换一张
取 消