jQuery UI自动完成功能:如何发送帖子数据? [英] jQuery UI autocomplete: how to send post data?

查看:69
本文介绍了jQuery UI自动完成功能:如何发送帖子数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery UI网站(公开来源):

$( "#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 );
    }
});

因此,正如我所见,没有任何方法可以通过 发布数据 "search.php"发出ajax请求.

So as I see there is no options how to make ajax request with post data to the "search.php".

但是我需要这样做,以便从先前的输入字段(当前字段: 城市,上一栏:国家).

But I need to do that to send some filter from previous input field (current field: city, previous field: country).

该怎么做?

谢谢!

推荐答案

尝试将源更改为使用$ .post的方法:

Try changing the source to be a method which uses $.post:

$("#birds").autocomplete({
  source: function (request, response) {
    $.post("search.php", request, response);
  },
  ...

这篇关于jQuery UI自动完成功能:如何发送帖子数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆