页面加载时AJAX调用可以正常工作,但会显示Onchange事件的CORS问题



我有此代码,并且在页面加载时可以按预期工作,但是当我尝试在选中复选框后试图拨打该呼叫时,它将显示请求标题x-csrf-toke not访问权限控制者允许在前反应中允许。

$.ajax
    ({
        type: 'POST',
        url: "https:/www.bb.com?uId=123&mId=123",
        headers: {
            "Accept": "application/json",
            "Content-Type": "application/json",
        },
        beforeSend: function (xhr) { xhr.setRequestHeader("Authorization", "Basic dTHIgdfgsjdhgfsgfjhsfghsfkjs879"); },
        dataType: 'json',
        success: function (data) {
            console.log(data);
        },
        error: function (xhr, status, error) {
            console.log(xhr);
            console.log(status);
            console.log(error);
        }
    });

and for checking:
$("input:checkbox[name=list]").click(function () {
   if ($(this).is(':checked')) {
do that call
}
});

有什么想法如何索取?

好的,因此由后端代码发布来修复。谢谢大家的帮助

最新更新