How do you send an ajax request every time that a form input field changes?

前端 未结 4 1477
花落未央
花落未央 2021-02-09 05:34

For example, there is an input field. Every time a user types a key into that field, it sends an AJAX request with whatever text is currently in that input, and does something

4条回答
  •  时光取名叫无心
    2021-02-09 06:07

    $('#yourInputId').keyup (function () {
        $.post('http://yoururl.com', { value: $(this).val() }).done(function (data) {
            $('#feedbackDivId').html(data);
        });
    });
    

提交回复
热议问题