Search code examples
jquerysemantic-ui

semantic-ui: get value of dropdown to send to api


I am trying to send the current value of the Search Dropdown to an API. I can't figure out what to send into urlData.value. I tried $(this) and $(this).val() and a number of other options but none worked.

$('.ui.dropdown').dropdown({
    minCharacters: 2,
    apiSettings: {
        cache: false,
        url: `http://localhost/search?text={value}`,
        urlData: {
            value:$(this)
        },
        ...
    }
});

Solution

  • Turns out I didn't have to use urlData at all. Just need to specify {query} in url.

    url: `http://localhost/search?text={query}`