且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

飞行前响应中的Access-Control-Allow-Headers不允许请求标头字段Access-Control-Allow-Origin

更新时间:2022-01-18 21:25:30

取出"headers""dataType".您的请求将如下所示:

Take out the "headers" and "dataType". Your request will then look like this:

$.ajax({
    type: "GET",
    url: "http://localhost:3000/readings",
    success: function (data) {
        var mem = data.mem.size/10000;
        var tick = {
            plot0: parseInt(mem)
        };
        callback(JSON.stringify(tick));
    }
});

您的标题正在触发预检请求.

Your headers are triggering the preflight request.

如果您使用的是Angular,我会高度建议不要将jQuery用于AJAX,而应使用Angular的

If you're using Angular, I'd highly suggest not using jQuery for AJAX and instead use Angular's built-in $http service.

我在ZingChart团队中. Holler,如果我们可以为您提供图表方面的帮助.

I'm on the ZingChart team. Holler if we can help with your charts.