0

再会。

代码:

$("#user-search_input").autocomplete({
    source: function( request, response ) {
      var form_data=$("#user-search_input").val();
      $.ajax({
        url: "./AutoCompliteFind/",
        dataType: "json",
        type: "POST",
        contentType: "application/json",
        data:{term: form_data},
        success: function(data) {
        //alert(data);

        }
      });
    },
    minLength: 2
});

请告诉我如何在./AutoCompliteFind/页面上获取值参数术语

PS:语言——PHP

PPS:如果我使用var_dump($_POST)我得到array(0) { }.

4

4 回答 4

0

使用json_decode() 函数将 json 转换为数组。例如:

$term = $_POST["term"];
$term = json_decode($term);
于 2013-07-04T23:33:33.050 回答
0
<?php
echo $_GET['term'];
?>

顺便说一句,如果您在 source 属性中指定一个字符串,您将获得对该文件的 ajax 调用:

$( "#birds" ).autocomplete({
  source: "search.php",
  minLength: 2,
  select: function( event, ui ) {
    log( ui.item ?
    "Selected: " + ui.item.value + " aka " + ui.item.id :
    "Nothing selected, input was " + this.value );
  }
});

http://jqueryui.com/autocomplete/#remote

于 2013-07-04T22:55:51.793 回答
0

这取决于您的服务器端编程语言,但一般来说,像这样(PHP):

$term = $_POST["term"];
于 2013-07-04T22:56:02.673 回答
0

尝试:

$string = file_get_contents('php://input');
于 2013-07-04T23:05:47.200 回答