令牌输入不起作用

令牌输入不起作用

本文介绍了令牌输入不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在获取变量"url"上的值,但是当变量分配给Tokeninput时,我的文本框没有得到该值.相反,当我直接将值传递给tokeninput时,我的文本框正在工作.将变量作为tokeninput传递..预先感谢

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
       });
   });

推荐答案

我相信您需要传递JSON对象作为参数,而不是JSON字符串.

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

尝试一下:

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

这篇关于令牌输入不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 21:01