0

Ajax'ом обращаюсь к Django:

$(document).ready(() => {
$("#end-of-registration").click((e) => {
    e.preventDefault();
    $.ajax({
        type: "POST",
        /*url: "http://localhost:8000/registration",*/
        url: "http://localhost:8000/registration",
        dataType: "text",
        success: function(data)
        {
            console.log(data);
        }
    });
});

В вьюхе возвращаю ответ (return HttpResponse('some text')), но в консоли выпадает ошибка:

Failed to load http://localhost:8000/registration: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Нужно установить в HttpResponse заголовок 'Access-Control-Allow-Origin: *', но пока все способы оборачиваются неудачей

2
  • Здесь решение вашей проблемы: stackoverflow.com/questions/22355540/…
    – AlTheOne
    28 сен 2018 в 3:59
  • Спасибо, как оказалось, мои методы тоже были правильными, просто возвращал значение не в том блоке 28 сен 2018 в 4:10

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Посмотрите другие вопросы с метками или задайте свой вопрос.