A
A
AntonIgin2017-04-26 18:34:52
Django
AntonIgin, 2017-04-26 18:34:52

How to send form data to multiple scripts?

It is necessary to send data from the form to two scripts:
1) a script on the server that saves information in the database;
2) a script on a third-party site to which there is no access and to which, in fact, a redirect is needed.
Let me give you a real example: before sending the data to the Yandex script, you need to save the order data in the admin panel. Attempts to send data to Yandex with a post-request were unsuccessful, since a redirect is needed.
Any ideas? I heard something about Ajax, started reading a tutorial about JS. But just in case, I decided to ask, what if I complicate it and there is an easier way.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Segey K., 2017-04-28
@AntonIgin

$('#buttonID').on('click', function(){
    var url = "your_view_url";

    $.ajax({
           type: "POST",
           url: url,
           data: $("form").serialize()
         });
    return '';
});

This is jQuery + ajax, so I sent data from the form to the view, without reloading the page.
At the moment of clicking on the button, a post is sent to views, which does what I need. And you already play with what you need)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question