Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript文件引用问题(使用jQuery)_Javascript_Jquery_Html_Filereference - Fatal编程技术网

Javascript文件引用问题(使用jQuery)

Javascript文件引用问题(使用jQuery),javascript,jquery,html,filereference,Javascript,Jquery,Html,Filereference,以前,我有过这样的经历: <head> <script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script> <script type="text/javascript"> var optPrompt = "- Select One -"; var subCats; var parentCats;

以前,我有过这样的经历:

<head>
    <script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script> 
    <script type="text/javascript">
        var optPrompt = "- Select One -";
        var subCats;
        var parentCats;
        var nextBtn;

        var ParentChanged = function() {
            ClearDescription();

            if (this.selectedIndex == 0) {
                $(subCats).html($("<option>").text(optPrompt));
            }


            $.getJSON('<%=Url.Action("GetChildCategories") %>', { parentId: $(this).val() },
                    function(data) {
                        subCats.options.length = 0;
                        $("<option>").text(optPrompt).appendTo(subCats);
                        $(data).each(function() {
                            $("<option>").attr("value", this.ID).text(this.Name).appendTo(subCats);
                        });
                    });
        }

        var DisplayDescription = function(catId) {
            $.ajax({
                url: '<%=Url.Action("GetDescription") %>',
                data: { categoryId: catId },
                dataType: 'html',
                success: function(data) {
                    $("p#categoryDescription").html(data);
                }
            });
        }

        var ChildChanged = function() {
            var catSelected = this.selectedIndex != 0;

            if (!catSelected) ClearDescription();
            else DisplayDescription($(this).val());
        }

        var ClearDescription = function() {
            $("p#categoryDescription").html('');
        }

        $(function() {
            parentCats = $("select#Category").get(0);
            subCats = $("select#Subcategory").get(0);
            nextBtn = $("input#nextButton").get(0);

            $(parentCats).change(ParentChanged);
            $(subCats).change(ChildChanged);
        });

    </script> 
</head>
然后,我将所有内联脚本放入一个文件myScript.js,并将我的HTML更改为:

<head>
    <script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script> 
    <script src="/Scripts/myScript.js" type="text/javascript"></script> 
</head> 
现在什么都没用了。我在IE7中打开了我的页面,页面错误如下:

电话号码:54 错误:未知名称

第54行恰好是我的外部javascript文件的最后一行


我做错了什么?

您是否在myScript.js中添加了