Semantic-ui: Search POST Method Instead of GET ?

Created on 18 Apr 2016  Â·  6Comments  Â·  Source: Semantic-Org/Semantic-UI

Is it possible to use .ui.search with POST method instead of GET ? Any examples is appreciated. Thank You!

<div class="ui search">
  <div class="ui left icon input">
    <input class="prompt" type="text" placeholder="Search GitHub">
    <i class="github icon"></i>
  </div>
</div>
$('.ui.search')
  .search({
    apiSettings: {
      url: '//api.github.com/search/repositories?q={query}'
    },
    fields: {
      results : 'items',
      title   : 'name',
      url     : 'html_url'
    },
    minCharacters : 3
  })
;
Should Post to Forum - See Readme Usage Question

Most helpful comment

@IonutBajescu I think I was asking about ''POST'' not GET which is default.

@jlukic There is no POST example that I could find. Can you give an example please ?

All 6 comments

Have you tried using the "method" option? Like this:

$('.ui.search')
  .search({
    apiSettings: {
      url: '//api.github.com/search/repositories?q={query}',
      method: 'GET'
    },
    fields: {
      results : 'items',
      title   : 'name',
      url     : 'html_url'
    },
    minCharacters : 3
  })
;

Method should have you covered. You can configure any normal API settings, see the api docs for more details.

@IonutBajescu I think I was asking about ''POST'' not GET which is default.

@jlukic There is no POST example that I could find. Can you give an example please ?

We mean, how to put {query} on the post parameter?

we have tried this:

    $('#search-user')
        .search({
            apiSettings: {
                url: window.location.href,
                method: 'POST',
                data: {
                    term: '{query}' // <--- this, but it doesnt replaced like on the `url` param
                }
            },
            fields: {
                results : 'items',
                title   : 'name',
                url     : 'html_url'
            },
            minCharacters : 3
        })
    ;


Hi @rizalgowandy, the search component automatically takes an input value and replaces {query} in a url with it. Here’s an example, see the “Network” tab in your browser’s developer tools to see the request: https://jsfiddle.net/19fb6uLv/

I'm using a "beforeSend" callback function in the apiSettings to modify the data like this:
https://jsfiddle.net/pkdukdjv

Was this page helpful?
0 / 5 - 0 ratings

Related issues

batata004 picture batata004  Â·  3Comments

iPaoo picture iPaoo  Â·  3Comments

rdzidziguri picture rdzidziguri  Â·  3Comments

ghost picture ghost  Â·  3Comments

larsbo picture larsbo  Â·  3Comments