V
V
voproser2019-08-17 14:38:34
AJAX
voproser, 2019-08-17 14:38:34

How to send data from html form via ajax jquery?

<form method="post" action="#" id="ajax_form" action="">
    <div class="row">
        <div class="col-6 col-12-mobile">
            <input type="text" name="email" placeholder="Email" />
        </div>
        <div class="col-6 col-12-mobile">
            <input type="password" name="password" placeholder="Пароль" />
        </div>
        <div class="col-12">
            <input type="button" id="btn" value="Регистрация" />
        </div>
    </div>
</form>

Already 100 times I tried to submit this form via ajax. DOES NOT WORK.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Web Dentist, 2019-08-17
@kgb_zor

The question is really elementary. But since you have tried a hundred times, we will try to help you.
First, include jquery.
Then try like this -

let form = $('#ajax_form').
 $.ajax({
                            url: form.attr('action'),
                            type: "POST",
                            data: form.serialize(),
                            async: false,
                            success: function (data) {
                                console.log(data);
                            }
                        });

And read more about ajaxSubmit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question