我有一个seb服务,这里是代码:
<WebMethod()>
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False, XmlSerializeString:=False)>
Public Function Names(ByVal a As String) As String
Dim nomi()() As String = New String(2)() {}
nomi(0) = New String() {"Windows", "IIS", "AspNet"}
nomi(1) = New String() {"Linux", "Apache", "PHP"}
nomi(2) = New String() {"Xml", "Soap", "JSon"}
Dim js As JavaScriptSerializer = New JavaScriptSerializer()
Dim strJSon As String = js.Serialize(nomi)
Return strJSon
End Function
$("#search2").mcautocomplete({
showHeader: true,
columns: columns,
source: function (request, response) {
$.ajax({
url: 'http:\\applicazioni.vsc300.it/Service.asmx/Names")',
data: "{ 'a': '" + request.term + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response(data.d);
},
}
)}
});
function customRenderItem(ul, item) {
var t = '<span class="mcacCol1">' + item[0] + '</span><span class="mcacCol2">' + item[1] + '</span>',
result = $('<li class="ui-menu-item" role="menuitem"></li>')
.data('item.autocomplete', item)
.append('<a class="ui-corner-all" style="position:relative;" tabindex="-1">' + t + '</a>')
.appendTo(ul);
return result;
}
var columns = [{name: 'Color', minWidth: '100px'}, {name: 'Hex', minWidth:'70px'}],
colors = [['Red', '#f00'], ['Green', '#0f0'], ['Blue', '#01f']];
$("#search").mcautocomplete({
showHeader: true,
columns: columns,
source: colors,
select: function(event, ui) {
this.value = (ui.item ? ui.item[0]: '');
return false;
}
});
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.19/themes/cupertino/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://applicazioni.vsc300.it/Scripts/jquery.mcautocomplete.js"></script>
<div style="margin:10px 10px;padding:8px;width:300px;" class="ui-widget ui-widget-content ui-corner-all">
<div style="margin:0 0 9px 4px;">Type in a color</div>
<!-- This is the input control that gets turned into the jquery ui widget -->
<input id="search" type="text" style="padding:12px;font-size:.8em;width:200px;"/>
</div>
search by service
<input id="search2" type="text" style="padding:12px;font-size:.8em;width:200px;"/>
返回一些字符串,但我想在我的页面中使用多列自动完成功能 正如您所看到的,第一个自动完成是正常的,第二个应该调用该服务不起作用