AJAX JSON до Python Flask: не удалось загрузить ресурс: сервер ответил со статусом 400 (BAD REQUEST) - PullRequest
0 голосов
/ 22 апреля 2020

Это первый раз, когда я пытаюсь передать данные от Json до flask, но я получаю эту ошибку. :5000/_get_post_json/:1 Failed to load resource: the server responded with a status of 400 (BAD REQUEST)

@app.route('/_get_post_json/', methods=['POST'])
def get_post_json():
    data = request.get_json()
    print(data)

    return jsonify(status="success", data=data)
var origin1 = $('#origin-input').val();
var destination1 = $('#destination-input').val();
window.drivername = `${data.firstname}`;
$.ajax({
   type: "POST",
   url: "{{ url_for("get_post_json") }}",
   contentType: "application/json",
   data: { origin: origin1, destination: destination1, name: window.drivername },
   dataType: "json",
   success: function(response) {
      console.log(response);
   },
   error: function(err) {
      console.log(err);
   }
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...