0x800a1391 - JavaScript的运行时错误:'jQuery的'未定义 [英] 0x800a1391 - JavaScript runtime error: 'jQuery' is undefined

查看:4785
本文介绍了0x800a1391 - JavaScript的运行时错误:'jQuery的'未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET的MVC4 Web应用程序。在这里面我有我的_Layout.cshtml,这反过来又加载默认主页/索引通常的HTML。一切工作正常。

I have a ASP .Net MVC4 Web application. In it I have my usual html for the _Layout.cshtml, which in turn loads the default Home/Index. All works fine.

在我的索引我也加载的局部视图。这工作也没关系。没有probs。

In my index I am also loading a partial view. This works fine too. No probs.

我使用的是用户界面工具从以下网站:

I am using a the UI tools from the following site:

http://www.keenthemes.com/$p$ PVIEW /的index.php?主题= METRONIC

问题是,它似乎是主要HTML4而不是MVC设计出来,所以我不得不调整它稍微得到它的工作就是我想要的盒子。 (没有什么超出了非常基本的)。例如,移动一个部分分离出来,索引和使用Renderbody()来加载它,因此实际的HTML结构不会改变。我有这个做了百万次,以确保我没有遗漏任何结束标记或其他任何可能导致我的问题。

The problem is it seems to be primarily HTML4 and not designed for MVC out of the box so I am having to tweak it slightly to get it to work the way I want. (Nothing beyond anything very basic). For example, moving one part out to the index and using Renderbody() to load it so the actual html structure never changes. I have done this a million times to be sure I am not missing any closing tags or anything else that could cause my problem.

至此没有问题的。一切加载,因为它应该。

Up to this point there is no problem at all. Everything loads as it should.

我继续创建第二View及其部分提取该网站的其他部分。像往常一样,宝宝的第一步。提取任何其他code之前,我只是用一个小的Hello World的第一页,并在部分类似的字符串,以确保它正常工作。这是

I continued to create a 2nd View and its partial to extract other parts of the site. As usual, baby steps first. Before extracting any other code, I just used a little "Hello World" in the first page, and a similar string in the partial to be sure it was working. It was.

现在,当我在url主页/ ActionName整个事情重新加载,因为它应该,但看起来可怕类型。我得到这个错误信息:

Now when I type in the url Home/ActionName the whole thing reloads as it should but looks horrible. and I get this error message:

0x800a1391 - JavaScript的运行时错误:'jQuery的'未定义

0x800a1391 - JavaScript runtime error: 'jQuery' is undefined

下面是我的code,明确定义它:

Below is my code which clearly defines it:

<!-- BEGIN CORE PLUGINS -->
<script src="assets/plugins/jquery-1.8.3.min.js" type="text/javascript"></script>
<script>
    jQuery(document).ready(function ()
    {
        App.init(); // initlayout and core plugins
        _Layout.init();
        _Layout.initJQVMAP(); // init index page's custom scripts
        _Layout.initCalendar(); // init index page's custom scripts
        _Layout.initCharts(); // init index page's custom scripts
        _Layout.initChat();
        _Layout.initDashboardDaterange(); //Red date range
        _Layout.initIntro(); //Pop up messages
    });
</script>

这点我对jQuery(文件)。就绪一部分,当我看到消息。

It points me to the jQuery(document).ready part when I see the message.

再次当我加载页面通常情况下,它工作正常。当我在自己的主页键入它工作正常。它只有当我键入主页/ AnythingElse,它给这个错误信息。即使我键入主页/应在索引文件加载,它给了我这个错误消息。

Again, when I load the page normally, it works fine. When I type Home on its own it works fine. Its only when I type Home/AnythingElse that it gives this error message. Even if I type Home/ which should load in the Index file, it gives me this error message.

jQuery的定义,那么,为什么会出现这种情况在回发?

jQuery is defined, so why is this happening on postback?

任何帮助是AP preciated。

Any help is appreciated.

推荐答案

尝试设置的src jQuery来从站点根绝:

Try setting the src for jQuery to be absolute from the site root:

<script src="/assets/plugins/jquery-1.8.3.min.js" type="text/javascript"></script>

请注意在 / 资产 - 当你的src路径不以启动 / 浏览器将尝试在你的榜样相对资产装入到当前路径,所以当你添加了结尾的斜线到首页它会尝试从

Note the / before assets - when your src path does not start with a / the browser will try and load the asset relative to the current path, so in your example when you add the trailing slash to Home it will try to load jQuery from Home/assets/plugins/...

这篇关于0x800a1391 - JavaScript的运行时错误:'jQuery的'未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆