$(document).ready(function () {
$('[id$=tagsinput]').tagsinput({
itemValue: 'value',
itemText: 'text',
typeahead: {
source: function (query) {
var str;
$.ajax({
type: "POST",
url: "CityNamesData.asmx/GetCities",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
str = data.d;
}
});
var str1 = $.getJSON(str);
return str1;
}
}
});
$('[id$=tagsinput]').tagsinput('add', { "value": 1, "text": "Amsterdam" });
$('[id$=tagsinput]').tagsinput('add', { "value": 4, "text": "Washington" });
$('[id$=tagsinput]').tagsinput('add', { "value": 7, "text": "Sydney" });
$('[id$=tagsinput]').tagsinput('add', { "value": 10, "text": "Beijing" });
$('[id$=tagsinput]').tagsinput('add', { "value": 13, "text": "Cairo" });
})
I am trying to save data coming from web method into str1 as follows
var str1 = $.getJSON(str);
return str1;
str1 saves data in the same format as it was previously saved in str.
But still when I have tried to return str1, its not showing suggestions into the textbox.
str and str1 are storing json data into the same format.But it is only showing suggestions when I am returning str.
Can anyone please tell me how to return this data coming from WebMethod so that it would show suggestions in textbox.
I dont know whats wrong with str1.