I am using JQuery Autocomplete, and want to populate it from a JSON Array read from a hidden Label.
This code:
string[] tags = { "Apple", "Orange", "Banana", "Lychee", "Pear", "Lemon" };
var json = JsonConvert.SerializeObject(tags);
lblJson.Text = json;
produces this result:
I am trying to then populate the autocomplete source with this array like this:
var availableTags = $("#lblJson").text();
$("#tbTag").autocomplete({
source:availableTags
});
but my autocomplete doesn't, err, autocomplete.
However, if I copy the JSON array directly into the Javascript code it works fine:
var availableTags = ["Apple", "Orange", "Banana", "Lychee", "Pear", "Lemon"];
$("#tbTag").autocomplete({
source:availableTags
});
