使jquery运行时出现问题 [英] problem getting jquery to run

查看:113
本文介绍了使jquery运行时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是一个真正的难题.通常我没有任何问题让jquery运行.

This problem is being a real ballache. Normally i dont have any problems getting jquery to run.

我正在用c#运行一个ASP网站.

I am running a asp web site with c#.

这是页面生成的html.当我单击ID测试按钮时,出现以下错误.

Here is the html generated by the page. When i click the button with id test i get the error below.

网页错误详细信息

Webpage error details

用户代理:Mozilla/4.0(兼容; MSIE 8.0; Windows NT 6.1;三叉戟/4.0; GTB7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)时间戳:15周三 2011年6月17:08:03 UTC

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E) Timestamp: Wed, 15 Jun 2011 17:08:03 UTC

消息:对象不支持此功能 属性或方法行:236字符:1 代码:0 URI: http://localhost:53294/FluidataPortal/connections/macRequest.aspx

Message: Object doesn't support this property or method Line: 236 Char: 1 Code: 0 URI: http://localhost:53294/FluidataPortal/connections/macRequest.aspx

-HTML

为清楚起见,仅显示relevent html.如果需要,我可以显示完整的

Just showing the relevent html for clarity. I can show the full if needed

<button id="test" onclick="test()">
Click me to test
</button>

-Javascript

--Javascript

/*!
 * jQuery JavaScript Library v1.6
 * http://jquery.com/
 *
 * Copyright 2011, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2011, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Mon May 2 13:50:00 2011 -0400
 */
JQUERY CODE. REMOVED FOR CLARITY

function test() {

    if (!busy) {
        $.get("ajax/RequestMac.aspx?user=Tomsquires&dsl=123", function(response, status, xhr) {
            alert(response);
        });

    }
}

推荐答案

您在JavaScript后面添加了jQuery.

You are including your jQuery after your JavaScript.

需要在JavaScript之前 加载jQuery.

jQuery needs to be loaded BEFORE your JavaScript.

OP的原始HTML在其jQuery包含之前显示了要加载的外部JS文件的包含.

The OP's original HTML showed an Includes to an external JS file being loaded before his jQuery includes.

我把我的放在这样的<body>元素的底部...

I put mine at the bottom of the <body> element like this...

        <script type="text/javascript" src="/ajax/jquery/jquery-1.6.min.js"></script>
        <script type="text/javascript" src="/ajax/jquery/myCustom.js"></script>
        <script type="text/javascript" language="JavaScript">
        //<![CDATA[
            $(document).ready(function(){
                //  my code
            });
        //]]>
        </script>
    </body>
</html>

这里是为什么.

HERE is why.

这篇关于使jquery运行时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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