Php 使用ajax jquery发送json数据上的链接

Php 使用ajax jquery发送json数据上的链接,php,json,jquery,Php,Json,Jquery,我使用自动建议使用 现在,当用户选择用户名时,我想通过该用户名的链接向用户发送消息 我的json数据是这样来的 { query:'hel', suggestions:["hello world","hell boy ","bac to hell"], data:["2","26","34"] } 现在我想让用户去做什么http://userProfile.php?uid=26 在select usernamesuppose user上选择地狱

我使用自动建议使用

现在,当用户选择用户名时,我想通过该用户名的链接向用户发送消息

我的json数据是这样来的

{
 query:'hel',
 suggestions:["hello world","hell boy ","bac to hell"],
 data:["2","26","34"]                       
}
现在我想让用户去做什么http://userProfile.php?uid=26 在select usernamesuppose user上选择地狱男孩 怎么做

更新: 我一步一步地描述我在做什么 我使用的是一个使用jQueryAjax的搜索框,当用户在输入框上写下一些文本时,我们会显示重新调整搜索的建议值

第一步。当用户写入至少2个字母时,将调用下面的函数in,其中我发送写入文本框的值。见鬼

<script type="text/javascript" language="javascript">
    var options, a;
    jQuery(function(){
       options = { serviceUrl:'rpc.php' };
       var a = $('#query').autocomplete({ 
        serviceUrl:'rpc.php',
        minChars:3, 
        delimiter: /(,|;)\s*/, // regex or character
        maxHeight:400,
        width:300,
        zIndex: 9999,
        deferRequestBy: 0, //miliseconds
      });
    });
 </script>
}

其中,包含用户名和数据的建议列表是user_表中的userid。上面的数据来自前端的一个div,其中用户名显示在一个列表中

第三步:现在,如果我使用向上箭头和向下箭头选择任何用户名,则该名称将填入输入框中, 步骤4:现在我想要的是,当用户选择usename时,页面自动转到该用户的配置文件部分userprofile.php?uid=2,如果您查看“如何使用”部分下的,您将看到可以添加onSelect回调函数:

 // callback function:
onSelect: function(value, data){ alert('You selected: ' + value + ', ' + data); },
现在,您应该能够访问数据,并将用户移动到所需页面

e、 g.类似于以下内容:

<script type="text/javascript" language="javascript">
var options, a;
  jQuery(function() {
    options = {
      serviceUrl: 'rpc.php'
    };
    var a = $('#query').autocomplete({
        serviceUrl: 'rpc.php',
        minChars: 3,
        delimiter: /(,|;)\s*/, // regex or character
        maxHeight: 400,
        width: 300,
        zIndex: 9999,
        deferRequestBy: 0, //miliseconds
        // callback function:
        onSelect: transferUser
      },
    });
  });

  function transferUser(value, data) {
    window.location.href = 'userprofile.php?uid=' + data;
  }    
</script>
请注意,我还没有测试过这个,但它应该会让您了解如何继续


还值得注意的是,jQuery UI的最新版本

我认为您指的是JSON,而不是jason。至于你的问题,你需要更清楚地说明你想做什么。@Abs这是json,谢谢你的指点,现在我更新了我的问题,请看
<script type="text/javascript" language="javascript">
var options, a;
  jQuery(function() {
    options = {
      serviceUrl: 'rpc.php'
    };
    var a = $('#query').autocomplete({
        serviceUrl: 'rpc.php',
        minChars: 3,
        delimiter: /(,|;)\s*/, // regex or character
        maxHeight: 400,
        width: 300,
        zIndex: 9999,
        deferRequestBy: 0, //miliseconds
        // callback function:
        onSelect: transferUser
      },
    });
  });

  function transferUser(value, data) {
    window.location.href = 'userprofile.php?uid=' + data;
  }    
</script>