#ajax
#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:
Проверьте Firebug или аналогичный инструмент, чтобы убедиться, что скрипт загружается. Он должен находиться в каталоге сценариев на том же уровне, что и этот HTML-файл. Или вы можете настроить src
атрибуты.