I will be storing an array in session that will contain data entered by the user (id numbers used to search in several different areas of the application)
I then want to return the values in this array that is residing in session as auto complete selections.
Getting the array into session and updating it is the easy part, getting it from session into the autocomplete isn’t as much so.
I’d rather use the array to do the auto complete instead of converting to json.
I’ve tried using '<%= SESSION("MEMBER_SEARCH_ARRAY") %>' as the source for the autocomplete but no dice.
Is it possible to do something like:
$.ajax({
url: "../ajax/MemberAuto.ashx",
dataType: "text",
success: function(data) {
$('#txtDealerNumber').autoComplete({ source: data }); // <- Object doesn't support this property or method error
},
error: function(xhr, status, error) { }
});
when MemberAuto.ashx contains:
Public Class MemberAuto : Implements IHttpHandler, IRequiresSessionState, IReadOnlySessionState
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/plain"
context.Response.Write(Join(context.Session("MEMBER_SEARCH_ARRAY"), ","))
context.Response.End()
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
unfortunately I get an error following the ajax call in the success.
Any input would be greatly appreciated
Assuming that you are using jQueryUI(seems like autocomplete is not a part of jQuery core), This can be easily implemented in this way. No need of ajax as
autocompleteautomatically does this.where the url
../ajax/MemberAuto.ashx?AutoCompletereturns(test it in the browser) in the format
see here for more details.
http://jqueryui.com/demos/autocomplete/#option-source
Edit1: If you really want to stick in your way. then you need to convert your string to array which can be done using
eval().ie.
for testing eval http://jsfiddle.net/wZkjZ/