Related to this: jquery doesnt go to error or success
I've got an old 1.1 asp.net/vb.net project that I need to add autocomplete to a textbox. I wrote a .asmx (the web service file) as such:
<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
This works fine as I can see the data when I run this .asmx file. Then I've read articles upon articles that say .net 1.1 did not support json / jsonp format and to use xml. So then I went on to embark on the jquery side to attach this autocomplete ui to my textbox. Here is what I tried:
$("#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);
}
});
},
});
Now when I run my app and use for instance google chrome I do not see any errors in the developer tools console pop up when I type in the textbox. So I am not sure if this is working or not. I tried to follow this stackoverflow answer: https://stackoverflow.com/a/7729147/168703 to see how this guy did it and i'm pretty sure I followed correctly? Can anyone tell what I am doing wrong please.