Код Jquery в моем приложении django не работает

У меня проблема с моим кодом Jquery. Я включаю мой файл скрипта - который зависит от jQuery - после jQuery. Так что я не знаю, в чем проблема.

HTML-страница, с которой я расширил jquery :

  <!-- Core JS -->
<!-- build:js assets/vendor/js/core.js -->
<script src="{% static 'main/vendor/libs/jquery/jquery.js' %}"></script>
<script src="{% static 'main/vendor/libs/popper/popper.js' %}"></script>
<script src="{% static 'main/vendor/js/bootstrap.js' %}"></script>
<script src="{% static 'main/vendor/libs/perfect-scrollbar/perfect-scrollbar.js' %}"></script>

<script src="{% static 'main/vendor/js/menu.js' %}"></script>
<!-- endbuild -->

<!-- Vendors JS -->

<!-- Main JS -->
<script src="{% static 'main/js/main.js' %}"></script>

<!-- Page JS -->
{% block js %}
{% endblock %}

HTML с кодом ajax

    <script>
  paypal
    .Buttons({
      createSubscription: function (data, actions) {
        return actions.subscription.create({
          plan_id: "my plan", // Creates the starter plan
        });
      },
      onApprove: function (data, actions) {
        $.ajax({
          type: "POST",
          url: "{% url 'payment-success' %}",
          data: {
            subscriptionID: data.subscriptionID,
            userId: "{{user.profile.uniqueId|safe}}",
            csrfmiddlewaretoken: "{{csrf_token}}",
          },
          sucess: function (data) {},
        });
      },
      onCancel: function (data) {
        $.ajax({
          type: "POST",
          url: "{% url 'payment-success' %}",
          data: {
            'userId': "{{user.profile.uniqueId|safe}}",
            'csrfmiddlewaretoken': "{{csrf_token}}"
          },
          sucess: function (data) {
            alert(data.result);
          }
        });

        alert("You have canceled your subscription");
      }
    })
    .render("#paypal-button-container-1"); // Renders the PayPal button
</script>

Мой views.py

from django.shortcuts import render, redirect, HttpResponse
from django.contrib.auth.models import User, auth
from django.contrib import messages

from django.contrib.auth.decorators import login_required
from django.contrib.auth.decorators import user_passes_test

from django.views.decorators.http import require_POST
from django.views.decorators.csrf import csrf_exempt

from django.http import JsonResponse

@login_required
def paypalPaymentSuccess(request):
    userId = request.POST['userId']
    print(userId)

    return JsonResponse({'result': userId})

Мой urls.py

    path('paypal-payment-success', views.paypalPaymentSuccess, name='payment-success'),

Помогите мне пожалуйста, мне нужно знать, почему не работает оповещение, которое показывает alert(data.result);?

Вернуться на верх