데이터베이스에서 사용자 이름을 바인드하려고하지만 일부 이상한 오류를 표시하는 방법이 있습니다. 내가 불을 지르고에서 확인 시도 Jquery 자동 완성이 프로덕션 서버에서 작동하지 않습니다.
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
<WebMethod()> _
Public shared Function GetAutoCompleteData(ByVal username As String) As List(Of String)
Dim result As New List(Of String)()
Using con As New SqlConnection("Data Source=foo; Initial Catalog=db;user id=foo; password=foo;")
Using cmd As New SqlCommand("select cust_name from customers where cust_name LIKE '%'[email protected]+'%'", con)
con.Open()
cmd.Parameters.AddWithValue("@SearchText", username)
Dim dr As SqlDataReader = cmd.ExecuteReader()
While dr.Read()
result.Add(dr("cust_name").ToString())
End While
Return result
End Using
End Using
End Function
처럼
ASPX 파일
<script type="text/javascript">
$(document).ready(function() {
SearchText();
});
function SearchText() {
$(".autosuggest").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/GetAutoCompleteData",
data: "{'username':'" + document.getElementById('txtSearch').value + "'}",
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (result) {
alert('error');
}
});
}
});
}
코드 뒤에이다. 넷 XHR.
Server Error in '/' Application.
Unknown web method GetAutoCompleteData.
Parameter name: methodName
스택 추적 :
[ArgumentException: Unknown web method GetAutoCompleteData.
Parameter name: methodName]
System.Web.Script.Services.WebServiceData.GetMethodData(String methodName) +178
System.Web.Handlers.ScriptModule.OnPostAcquireRequestState(Object sender, EventArgs eventArgs) +204
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
동일한 코드가 로컬 컴퓨터에 노력하고 있습니다 참고 있지만 프로덕션 서버에 포스트 탭에서이
JSON
username
"j"
Source
{'username':'j'}
는 응답 탭에서 그것을 보여줍니다 . 콘솔에서 는 내가 잘못 가고 어디 이해할 수 없습니다입니다
"NetworkError: 500 Internal Server Error - http://foo.com/Default.aspx/GetAutoCompleteData"
을 표시합니다. 위의 자바 스크립트에서 오류 경고를 표시하고 있습니다. 누구든지 도와 줄 수 있습니까?
당신이 보내는 AJAX에서 올바른 데이터 형식은? – Dave
프로덕션 서버에'GetAutoCompleteData' 메소드가 있습니까? 철자가 맞습니까? –