ajax调用中的CORS问题[关闭]

问题描述 投票:-2回答:1

我在ajax调用中遇到CORS问题,但我也警告不要重定向到URL。

错误:

jquery-1.10.2.min.js:6跨域读取阻止(CORB)阻止了MIME类型为text / html的跨域响应“重定向url”。有关更多详细信息,请参见chromestatus.com/feature/5629709824032768。

我的代码:

 $.ajax({
                url: 'here are url',
                dataType: 'JSONP',
                headers: {
                    'Set-Cookie': 'Secure;SameSite=none;',
                    'Access-Control-Allow-Origin': '*',
                },
                jsonpCallback: 'callbackFnc',
                type: 'GET',
                async: false,
                crossDomain: true,
                contentType: 'text/html;charset=utf-8',
                success: function (data) {
                    debugger;
                },
                failure: function (data) {
                    debugger;
                },
                complete: function (data) {
                    debugger;
                    if (data.readyState == '4' && data.status == '200') {
                        console.log("success")
                    }
                    else {
                        console.log("failed")
                    }
                }
            });
javascript jquery ajax cors
1个回答
-3
投票

我认为您的标头向后,为JS服务的服务器应具有响应标头:

Access-Control-Allow-Origin': '*'

这不属于请求标题。

© www.soinside.com 2019 - 2024. All rights reserved.