0
當我張貼到我的asmx web服務,返回此錯誤:阿賈克斯後返回錯誤
未能創建類型「myProjectName.AutoCompleteWebService」。
我嘗試了StackOverflow和許多其他網站的所有答案,但沒有一個在我的情況下工作。
JQuery的
$("#txtSearchKeyWord").autocomplete({
source: function (request, response) {
$.ajax({
url: "AutoCompleteWebService.asmx/IndentifySearch",
data: "{ 'keyWord': '" + request.term + "','Lang': 'En' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) { return data; },
success: function (data) {
$(currentElement).css({ "background": "rgb(255, 255, 255) none repeat scroll 0% 0%/auto padding-box border-box" });
response($.map(data.d, function (item) {
return {
value: item
}
}))
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
},
open: function (event, ui) {
//$(".ui-autocomplete").css("left", (parseInt($(".ui-autocomplete").css("left").replace("px", "")) - 114).toString() + "px");
},
minLength: 3,
appendTo: "#Autocontainer"
});
ASMX
<%@ WebService Language="C#" CodeBehind="AutoCompleteWebService.asmx.cs" Class="RoyalTours.AutoCompleteWebService" %>
C#
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class autocomp : System.Web.Services.WebService
{
[WebMethod]
public List<string> IndentifySearch(string keyWord)
{
string currentPageURL = HttpContext.Current.Request.Url.AbsolutePath;
List<Package> olstPackage = null;
olstPackage = new PackageRepository().SearchPackage(keyWord);
List<string> olstResult = null;
if (olstPackage.Count > 0)
{
olstResult = new List<string>();
for (int indexCountry = 0; indexCountry < olstPackage.Count; indexCountry++)
{
olstResult.Add(olstPackage[indexCountry].KeyWord);
if (olstPackage.Count <= 0)
{
olstResult.RemoveAt(indexCountry);
}
}
}
return olstResult;
}
}
是你是對的,我覺得我很累,所以所以我也沒注意我的類名感謝您的幫助,這是一個真正的答案.... –
高興得到了幫助! – Santi
非常感謝... :) –