jQuery UI autocomplete: how to send post data?

后端 未结 5 1990
伪装坚强ぢ
伪装坚强ぢ 2021-02-20 17:25

From jQuery UI site (veiw source):

$( \"#birds\" ).autocomplete({
    source: \"search.php\",
    minLength: 2,
    select: function( event, ui ) {
        log(          


        
5条回答
  •  天涯浪人
    2021-02-20 18:09

    The following worked well for me. I needed some custom data, so I pulled the search "term" term: request.term out of the request as follows:

      jQuery('.some-autocomplete').autocomplete({
        source: function(request, response) {
          jQuery.post(ajaxurl, {action: 'some_content_search', type: type, term: request.term}, response, 'json');
        },
        minLength: 2,
        ...
    

提交回复
热议问题