Ajax建议错误ylib未定义

时间:2011-10-28 15:09:56

标签: ajax

您好我是AJAX的新手我一直在尝试让本教程发挥作用。我一直收到错误: Microsoft JScript运行时错误:'ylib'未定义

这正是我想要做的: http://www.webonweboff.com/widgets/ajax/ajax_suggest.aspx#API

代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ajaxServer.aspx.cs" Inherits="DynamicSearch.ajaxServer" %>

<!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="Scripts/ajaxtcr.js" type="text/javascript"></script>
    <script src="Scripts/x_core.js" type="text/javascript"></script>
    <script src="Scripts/y_AjaxSuggest.js" type="text/javascript"></script>
    <script src="Scripts/y_util.js" type="text/javascript"></script>
    <script src="Scripts/ylib.js" type="text/javascript"></script>

<style>
    span.suggestions {
        background-color: #EBEBEB;
        overflow: hidden;
        padding:0;
        margin:0;
    }
    span.suggestion,
    span.selected-suggestion {
        border: 0;
        background-color: #EBEBEB;
        font-weight: normal;
        height: 18px;
    }
    span.selected-suggestion,
    span.selected-suggestion span.match {    
        background: #006699;
        color: white;
        cursor: pointer;
    }
    span.match {    
        text-decoration: underline;
    }
    span.no-match {
        font-weight: bold;
        color: #0000FF;
    }
</style>
<!--[if IE 6]>
<style>
    span.suggestions  {  
        margin-left: -15px;
    }
</style>
<![endif]-->
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Suggest textbox <input type="text" id="Text1" name="txtInput" />
<br /><br />
Another one textbox <input type="text" id="Text2" name="txtInput2" />
<br />
    </div>
    <script type="text/javascript">
        var suggest, suggest2;

        window.onload = MyOnLoad;
        function MyOnLoad() {
            //first suggestion object (use default options)
            suggest = new ylib.widget.AjaxSuggest('txtInput',
                        'ajaxServer.aspx?action=suggest');
            //second suggestion object (use custom options)
            var options = ylib.widget.AjaxSuggest.DefaultOptions();
            options.maxSuggestions = 5;
            options.params = ["action=suggest2"];
            options.expectValueAndText = true;
            options.useValueNotText = true;
            options.showNoMatchMessage = true;
            options.useTimeout = false;
            suggest2 = new ylib.widget.AjaxSuggest('txtInput2',
                        'ajaxServer.aspx', options);

        }
</script>
    </form>
</body>
</html>

我做错了什么?提前谢谢。

1 个答案:

答案 0 :(得分:0)

签入Firebug或类似工具以确保脚本正在加载。它需要位于与该HTML文件相同级别的Scripts目录中。或者您可以调整src属性。