G
G
Gennady2020-01-15 21:31:18
Web development
Gennady, 2020-01-15 21:31:18

Why is the ajax form not working?

I have an html form:

<form id="mt_forms" action="https://money.yandex.ru/eshop.xml" method="post">
<input>...
...
<input type="submit" class="submitting" value="Оплатить">
</form>


There is a script that sends form data to a .php script before sending it to Yandex

$(function () {
        $('form').on('submit', function (e) {
            e.preventDefault();
            $.ajax({
                type: "POST",
                url: "/form_sent.php",
                data: $('form').serialize(),
                // async: false,
                success: function() {
                    return true;
                }
            });
        });
    });


the php script itself contains several curls that send data to all sorts of CRMs.

Response from /form_sent.php : 200OK, contains some debug crap like:
Авторизация прошла успешно<pre>NULL
</pre><pre>NULL
</pre>


When you click on submit, the data is successfully sent to all curls from form_sent.php, but nothing happens further. What could be the problem?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
B
Barmunk, 2019-04-02
@Barmunk

// http://site.ru/post?id=1&value=2

$id = $request->get('id'); // 1
$value = $request->get('value'); // 2
$array = $request->all(); // ['id' => 1, 'value' => 2]

C
Crash XD, 2019-04-03
@crashxd

Request: dipl/test=2
Forgot about the sign "?". Correct would be: dipl/ ? test=2
Input::get('number') returns null.
You pass the parameter to test, but you get number? No wonder it will be null)
If you pass the parameter correctly, then it can be received in the controller without problems, following the documentation .

G
Gennady, 2020-01-15
@theblackpost

e.preventDefault(); - superfluous

L
Lev Zabudkin, 2020-01-15
@zabudkin

}); - superfluous

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question