I am trying to make a search function on my jquery mobile page, 

HTML:

```html
    <input type="search" placeholder="Search" id="searchbar" />
    <ul data-role="listview" id="searchlist"></ul>

```

As a user is searching, results will be appended to the listview.

I want the following code to run everytime a letter is typed into the search bar? How do I accomplish this?

```js
    if (searchbar.val().length > 2)
    {
        $.ajax({
            url: "http://clubbedin.zymichost.com/search.php",
            type: "post",
            crossDomain: true,
            data: {
                'q': value,
                'userID': userID
            },
            success: function(data) {
                var json = jQuery.parseJSON(data);
                for (var i = 0; i < json.length; i ++)
                {
                    html += '<li><a data-option-id=\"' + json[i].optionid + '\">' + json[i].optionname + '</a></li>';
                }
                $('searchlist').append( html );
                $('searchlist').listview( "refresh" );
            }
        });
     }

```

Any help will be appreciated. Thanks!