Input input box to input delay request (search from time to time)

Stop 1s on request when input is getting focus

        var timeoutId = 0;
        $('#id').off('keyup').on('keyup', function (event) {
            clearTimeout(timeoutId);
            timeoutId = setTimeout(function () {
                    $.ajax({
                        url: '__MODULE__/Base/getSearchStation',
                        dataType: 'json',
                        data: {'search': ''},
                        type: 'POST',
                        success: function (re) {
                           //do something
                        }
                    });
            }, 1000);
        });

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326090885&siteId=291194637