관련 항목 : jquery doesnt go to error or success자동 완성을 텍스트 상자에 어떻게 연결합니까?
텍스트 상자에 자동 완성 기능을 추가해야하는 이전 1.1 asp.net/vb.net 프로젝트가 있습니다. 나는 같은이 .asmx (웹 서비스 파일)을 썼다 :
<WebMethod()> _
Public Function GetTags() As String()
Dim arr() As String = BindTags()
Return arr
End Function
Private Function BindTags() As String()
Dim cmdSelect As SqlCommand
Dim conMyData As SqlConnection
Dim reader As SqlDataReader
Dim myList As New ArrayList
'try and make a connection
Try
conMyData = New SqlConnection(ConfigurationSettings.AppSettings("strConn"))
cmdSelect = New SqlCommand("select_tags_grid", conMyData)
With cmdSelect
.CommandType = CommandType.StoredProcedure
'add parameters
.Parameters.Add("@SortOrder", SqlDbType.TinyInt).Value = 1
'check the clientid
conMyData.Open()
reader = cmdSelect.ExecuteReader(CommandBehavior.CloseConnection)
End With
While (reader.Read())
myList.Add(CType(reader("Tag"), String))
End While
Dim arr() As String = CType(myList.ToArray(Type.GetType("System.String")), String())
Return arr
Catch e As Exception
'clean up and close resources
Throw e
Finally
cmdSelect = Nothing
conMyData.Close()
conMyData = Nothing
End Try
End Function
나는이이 .asmx 파일을 실행할 때 데이터를 볼 수있는이 잘 작동합니다. 그렇다면 .net 1.1이 json/jsonp 형식을 지원하지 않고 xml을 사용한다고 말하는 기사를 읽었습니다. 그래서 나는이 자동 완성 기능을 내 텍스트 상자에 첨부하기 위해 jquery 측에 착수했다. 여기에 내가 뭘하려 : 이제
$("#txtTags").autocomplete({
minLength: 0,
source: function(request, response) {
$.ajax({
type: "POST",
url: "GetTags.asmx/GetTags",
dataType: "xml",
contentType: "text/xml; charset=utf-8",
success: function(xml) {
alert("hi");
// Completion logic goes here
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
},
});
내 응용 프로그램을 실행하고 나는 텍스트 상자에 입력 할 때 팝업 개발자 도구 콘솔에 오류가 표시되지 않는 경우 구글 크롬을 위해 사용하는 경우. 그래서 이것이 작동하는지 아닌지 잘 모르겠습니다. 이 stackoverflow 대답을 따르려고했는데 : https://stackoverflow.com/a/7729147/168703 이 녀석이 그것을 어떻게했는지 그리고 나는 정확하게 따라 갔는지 확신합니까? 아무도 내가 뭘 잘못하고 있는지 말할 수 없습니까.
지원되는 버전의 .NET으로 간단하게 업그레이드하는 것이 더 쉬워 질 수 있습니다. 아마도 .NET 2.0 일 것입니다. –
@ JohnSaunders 네, 분명히 이해합니다. 우리가 .net 2.0으로 업그레이드 할 수없는 이유가 있습니다. 나는 내가 매우 가깝다고 생각하지만 여전히 파이 조각을 놓치고있다 ... http : //stackoverflow.com/questions/15957113/jquery-doesnt-go-to-error-or-success – oJM86o
나는 이것을 게시하려했다. 링크 : http://stackoverflow.com/questions/15957113/jquery-doesnt-go-to-error-or-success – oJM86o