JQuery - Microsoft JScript运行时错误:预期的对象

时间:2010-07-01 13:27:42

标签: jquery

以下是我的.aspx页面的内容,“jquery-ui-1.7.1.custom.min.js”与.aspx文件位于同一位置。当我通过调试运行网站时,我得到以下错误。我知道我在这里非常遗憾。任何线索?

错误: -

Microsoft JScript runtime error: Object expected

当我在没有调试的情况下运行时,我收到以下javascript错误: -

Line: 10
Error: 'jQuery' is undefined

ASPX页面内容: -

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <script>$(function () { alert('hello') });</script> 

    </div>
    </form>
</body>
</html>

3 个答案:

答案 0 :(得分:11)

jQuery UI不包含基本jQuery。您需要在UI-js之前导入它。

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

..弗雷德里克

答案 1 :(得分:0)

要解决此错误,我们需要添加jquery library引用

答案 2 :(得分:0)

我在ASP网站上也遇到了同样的问题。我从min.js链接调用Jquery,并通过将Jquery添加到我的项目中并改为调用来解决了该问题。

这很糟糕:

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

我转到浏览器中的js链接,将页面的内容复制到我的项目中的文件中(在scripts文件夹中),然后这样调用它:

<script src="Scripts/jquery-1.12.4.min.js" type="text/javascript"></script>

Chrome使用URL版本没有任何问题,但是Internet Exploder出于某些原因出现了问题。

相关问题