JQuery - Microsoft JScript runtime error: Object e

2020-07-22 09:15发布

Below is the content of my .aspx page and the "jquery-ui-1.7.1.custom.min.js" is in the same location as the .aspx file. When I run the website with debugging, I get the below error. I know I am terribly missing something here. Any clue?

Error :-

Microsoft JScript runtime error: Object expected

When I run without debugging, I get the following javascript error:-

Line: 10
Error: 'jQuery' is undefined

ASPX page content:-

<%@ 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>

标签: jquery
3条回答
SAY GOODBYE
2楼-- · 2020-07-22 09:58

I had this same issue with an ASP website. I was calling Jquery from the min.js link, and resolved the issue by adding Jquery to my project and calling that instead.

This was bad:

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

I went to that js link in my browser, copied the contents of the page to a file in my project (in the scripts folder) and called it like this instead:

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

Chrome didnt have any problems using the URL version, but Internet Exploder did for some reason.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2020-07-22 09:59

to resolve this error we need add jquery library refernce

查看更多
聊天终结者
4楼-- · 2020-07-22 10:00

jQuery UI doesn't inlucde base jQuery. You need to import that before the UI-js.

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

..fredrik

查看更多
登录 后发表回答