From 663e7ac4be5ad32375dae85eaccae2ab4169969c Mon Sep 17 00:00:00 2001 From: ArtemB Date: Thu, 13 Jul 2023 15:53:39 +0300 Subject: [PATCH] 0.0.17 send new route form v2 --- static/js/sendNewRoute.js | 14 ++++++++++---- templates/blocks/profile/b_new_route.html | 6 +++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/static/js/sendNewRoute.js b/static/js/sendNewRoute.js index 15be44e..0487668 100644 --- a/static/js/sendNewRoute.js +++ b/static/js/sendNewRoute.js @@ -1,19 +1,25 @@ -function sendRoute(){ +function sendRoute(el){ + event.preventDefault() + let form = el.form; + let formData = new FormData(form); $.ajax({ headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, - url: '/ru/user_account/new_route_view/', + url: '/ru/routes/create_route/', type: "POST", // async: true, cache: false, processData: false, contentType: false, // enctype: 'json', - // data: {}, + data: formData, success: function(data){ console.log('data received') // location.href = '/profile' - document.querySelector(".info_profile").innerHTML = data.html + // document.querySelector(".info_profile").innerHTML = data.html + }, + error: function (data, exception){ + document.querySelector(".new_route").innerHTML = data.responseJSON.html } }); } diff --git a/templates/blocks/profile/b_new_route.html b/templates/blocks/profile/b_new_route.html index dfbbb10..7c76cb2 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -1,4 +1,4 @@ -
+ {% csrf_token %}
@@ -66,8 +66,8 @@
- - + +