Send a post from JavaScript without rebooting
15 USDImagine that the task of making a normal vote is easier.There are three buttons.Pressing the button occurs, sending the POST request to the page "postzapros.html"
The value button is transferred, and
The original is also transmitted by csrfmiddlewaretoken to protect the request to understand exactly what the request is made from our project.After that, all the buttons disappear, and something of three appears in their place:
Interesting
Interesting
Interesting
Thus, the tasks:
1) Make a POST request by pressing the button without re-starting the page.The processing will take place in the Python script.2) Cover the buttons and show one of the three depending on which button you have pressed.3) Do it safely.That is, to invent how to make sure the server receives the request from the right place or from the right user.Or propose another solution so that when you press the button there is no reboot of the page, but the data must be entered in the BD.
Проект(сайт) выполнен на python Django.
Ваш код нужно выполнить на JavaScript
Представьте, что задача сделать обычное голосование, только проще.
Есть три кнопки.
<div class="container btn_like col-lg-4">
<button class="..." type="submit" name="golos" value="1">
</div>
<div class="container btn_like col-lg-4">
<button class="..." type="submit" name="golos" value="2">
</div>
<div class="container btn_like col-lg-4">
<button class="..." type="submit" name="golos" value="3">
</div>
Нажимая на кнопку происходит, отправка POST запроса на страницу "postzapros.html"
Передается value кнопки, а также
<input type="hidden" name="user_id" value="10">
<input type="hidden" name="state_id" value="100">
В оригинале еще передается csrfmiddlewaretoken для защиты запроса, чтобы точно понимать, что запрос сделан из нашего проекта.
После этого все кнопки исчезают, а вместо них появляется что-то одно из трех:
<div class="container btn_like col-lg-4">
<span class="label button_like metka">Интересно</span>
</div>
<div class="container btn_like col-lg-4">
<span class="label button_0 metka">Интересно</span>
</div>
<div class="container btn_like col-lg-4">
<span class="label button_dislike metka">Интересно</span>
</div>
Итак, задачи:
1) Сделать POST запрос при нажатии кнопки без перезагрузки страницы.
Обработка будет происходить в скрипте питона.
2) Скрыть кнопки и показать одно из трех в зависимости какую кнопку нажали.
3) Сделать это безопасно. То есть придумать, как убедиться серверу в получении запроса с правильного места или от правильного пользователя.
Или предложить другое решение, чтобы при нажатии кнопки не было перезагрузки страницы, но при этом данные должны заноситься в БД
Client's feedback on cooperation with freelancer
Send a post from JavaScript without rebootingEverything is great. I would put 10 out of 10.
But there is one strange thing in the work itself:
It solves programming tasks quickly and correctly, but sometimes as if it “subduces” on easy things.
And it is necessary to make accents and duplicate information from the task to make sure before performing,
This is how the programming has read and understood it. They are busy, everyone is running, everyone is running.
Don’t be offended by the artist.)
Profile deleted | Safe
Freelancer's feedback on cooperation with client
Send a post from JavaScript without rebootingThe Lion is a great customer, clear TZ, fast check, constant online. I recommend !
Profile deleted | Safe
-
289 5 0 Hello to you. The button is ready, the button is ready. I am ready to write a script.
Здравствуйте. Вёрстка полей, кнопок готова? Готов написать скрипт.
-
2941 65 4 3 Good day !
I do, token if django is formed - I'll take it.
I work quickly, read the reviews, call me!
Добрый день!
Сделаю, токен если на django формируется - подхвачу.
Работаю быстро, читайте отзывы, обращайтесь!
-
250 12 0 Good time of day.
Ready to take this task, nothing difficult.
Доброго времени суток.
Готов взяться за эту задачу, ничего сложного
-
3124 88 3 4 Hello the Lion!
Ready to implement the Ajax request you need.
With respect, Yuri
Здравствуйте, Лев!
Готов реализовать необходимый вам ajax запрос.
С уважением, Юрий
Current freelance projects in the category JavaScript
Підключити інтернет оплату на сайт еквайринг monobank до сайтуДоброго часу. Потрібно зробити інтернет оплату для сайту написаному на php. Підключити інтернет еквайринг monobank до сайту написанного на php. Документація монобанку тут https://api.monobank.ua/docs/acquiring.html Сайт - sopamart.com.ua JavaScript, PHP ∙ 6 proposals |
Sass/css/bootstrap frontend developer
77 USD
I am looking for an experienced sass/css/bootstrap frontend developer, whose core business is frontend development and not just does this on the side next to other work. I need to have some design changes implemented on an existing website. These changes need to be applied by… JavaScript, Web programming ∙ 6 proposals |
Landing page on Next.jsIt is necessary to develop the landing page using the following range of technologies: Next.js, Redux, Tailwind. There are 3 versions of the site, namely the desktop, tablet and mobile versions. Design in made in Figma, the link is listed below. It is also necessary to realize… HTML and CSS, JavaScript ∙ 24 proposals |
Search for a frontend developer. JS, React
773 USD
Hello to you. We need a person who has experience working with technologies: React.js, Next.js, html, css, javascript. Podonos, founded in the United States in 2024, was founded by experienced former Google employees. Our service evaluates the efficiency and performance of… JavaScript, Web programming ∙ 24 proposals |
Opencart 2.1 - Нова пошта API, доробка модуля
34 USD
ТЗ: https://docs.google.com/document/d/1eaMmqEBuKOtk_K1X-NFXG_47GGwO77YeR6q355lKa-I/edit?usp=sharing Для виконання і знайомства із завданням будуть надані доступи до тестового серверу. JavaScript, PHP ∙ 1 proposal |