未捕获的ReferenceError:jQuery未定义“jquery-ui.js:338”

时间:2012-11-16 16:55:46

标签: jquery

我的jquery脚本引用是:

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js" type="text/javascript"></script>

我使用的是Chrome版本23.0.1271.64 m   - 我在第338行收到错误

})( jQuery );  //--> line 338 is highlighted 

这是我的第一个并寻找答案。

我正在学习如何使用API​​并拥有一个简单的网页

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
    <meta http-equiv="PRAGMA" content="NO-CACHE" />

    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function() {
        $( "#edit-user" )
                .button()
                .click(function() {
                    $( "#dialog-form" ).dialog( "open" );
                });         
     });
    </script>

</head>
<body>
<button id="edit-user">Edit User</button>
<div id="dialog-form" title="Radio Dialog">
        <form>
            <fieldset>
                <input type='radio' value='A' name='myRadio'>A
                <input type='radio' value='B' name='myRadio'>B
                <input type='radio' value='C' name='myRadio'>C
            </fieldset>
        </form>
    </div>
</body>
</html>

2 个答案:

答案 0 :(得分:0)

由于您提供的信息有限,我假设您希望打开som类型的对话框,对吧?

你的对话框实际上已经存在但是,为了看到发生了什么事情,先从隐藏它开始(但是当你稍后实现它时使用.css来实现):

<div id="dialog-form" title="Radio Dialog" style='display:none;'>

然后看起来你需要在打开它之前创建对话框。这很可能是阻止你前进的原因:

$(function() {

        $( "#dialog-form" ).dialog({
            autoOpen: false      
        });      

        $( "#edit-user" ).click(function() {
                    $( "#dialog-form" ).dialog( "open" );
         });         
     });

查看此jsfiddle

希望这可以帮助您解决任何问题!

答案 1 :(得分:-1)

您需要首先包含jquery