Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
how to add the web method as source to bootstrap tags inputs. i did the following stuff but it is not working. it is not showing auto suggest
JavaScript
$(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);
                         //var str = $.getJSON('assets/cities.json');
                         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" });
         })

If we retrive the data using .json file then it is working fine.
please help me.thanx in advance
Posted
Comments
Shemeemsha (ഷെമീംഷ) 20-Sep-14 10:15am    
Any console error?
[no name] 22-Sep-14 0:14am    
no

1 solution

 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900