token input not working

十年热恋 提交于 2020-01-06 07:51:40

问题


I am getting values on variable "url" but my textbox not geting that values when variable assigned to Tokeninput..instead when i pass values directly to tokeninput my textbox is working..Finally i need to read my text box when i pass variable as tokeninput.. Thanks in advance

<script type="text/javascript">
   $(document).ready(function () {
       var url;
       $.ajax({
           type: "POST",
           url: "Tokeninput.aspx/GetData",
           contentType: "application/json; charset=utf-8",
           data: JSON.stringify({ Locale: 'en-US' }),
           datatype: 'json',
           async: false,
           success: function (data) {
               xmlDoc = $.parseXML(data.d);
               $xml = $(xmlDoc);
               $title = $xml.find("status");
               if ($title.attr("code") == "0") {
                   url = ($title.text());
               }
           },
           error: function (e) {
               alert("check once...");
           }
       });
       alert(url);
       $("#myTextBox").tokenInput([{"name":"Bhai"},{"name":"Bhargavi"},{"name":"Bhargav"},{"name":"Akka"},{"name":"Amma"},{"name":"Anil"},{"name":"Amar"}], {
       //$("#myTextBox").tokenInput(url, {
           theme: "facebook",
           preventDuplicates: true
       });
   });


回答1:


I believe you need to pass a JSON object as the parameter, not a JSON string.

Try this:

$("#myTextBox").tokenInput(JSON.Parse(url), {
           theme: "facebook",
           preventDuplicates: true
       });


来源:https://stackoverflow.com/questions/25664448/token-input-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!