[英]Runtime Error: Object Expected
I have a jQuery UI which is doing simple autocomplete function. 我有一个正在执行简单的自动完成功能的jQuery UI。 Autocomplete is coming via Web Service.
自动完成功能是通过Web服务来的。
This is the sample of my jQuery: 这是我的jQuery示例:
<script type="text/javascript">
$(document).ready(function () {
$('[id$="tbSearch"]').autocomplete({
url: '/WebService/SearchLookUp.asmx/ReturnEntity',
width: 300,
max: 10,
delay: 100,
cacheLength: 1,
scroll: false,
highlight: false
});
});
And this is the sample of my web service: 这是我的Web服务的示例:
public class SearchLookUp : System.Web.Services.WebService
{
[WebMethod]
public string []ReturnEntity(string prefixText)
{
using (TestDataContext search = new TestDataContext())
{
var tr = from p in search.Entities
where p.Name.StartsWith(prefixText)
select p.Name;
return tr.ToArray<string>();
}
}
}
When I am running this web service in the browser and passing parameters: 'ST' I am getting these results: 当我在浏览器中运行此Web服务并传递参数:“ ST”时,我得到以下结果:
<?xml version="1.0" encoding="utf-8" ?>
- <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<string>Steve</string>
<string>Star</string>
<string>Steve D</string>
<string>Star Route</string>
<string>Staffing</string>
<string>Strategic</string>
<string>Staci</string>
<string>Stevens</string>
<string>Starr</string>
</ArrayOfString>
Now the problem is that as soon I am entering anything on my textbox (tbSearch) I am getting MS jScript Error: Object Expected in 现在的问题是,一旦我在文本框(tbSearch)中输入任何内容,我就会收到MS jScript错误:预期对象
jQuery-ui-1.8.11.custom.min.js
jQuery-ui-1.8.11.custom.min.js
At line this: 在此行:
{this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:a},this.response)}
You may need to check your syntax on the autocomplete object 您可能需要检查自动完成对象的语法
based on this TextBox AutoComplete with ASP.NET and jQuery UI 基于此文本框自动完成功能并带有ASP.NET和jQuery UI
source:
method is built to call the ajax, looks like you also need to specify the data:
to be sent to the web service source:
方法是用来调用ajax的,看起来您还需要指定data:
要发送到Web服务
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.