??yy 2016-06-10 16:21 采纳率: 0%
浏览 131

Ajax中的CORS插件Chrome

I'm making cross origin ajax requests using jquery and I wanted to set headers in the request like this-- but it says that it is an improper request:

   $.ajax({
        url: address,
        headers:{
           'Access-Control-Allow-Origin': '*' 
         }
        success: function(result) {
            pipelineCallback(result, guid_key, j, missing_program);
        },
        error: function(result) {
            console.log(result);
        },
        async: true
    });

Caveat: When I don't set the header and use this CORS chrome plugin the cross-origin request goes through fine... whats the issue?

Plugin link(theres a public github repo too): https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en

  • 写回答

1条回答 默认 最新

  • weixin_33721344 2016-06-10 16:25
    关注

    Access-Control-Allow-Origin is a response header, not a request header.

    The CORS browser plugin fakes adding it to the response.

    Adding a non-standard header to a request triggers a preflight OPTIONS request which requires a specific kind of response to tell the browser that it is OK to make the request with the non-standard header.

    Adding Allow-Control-Allow-Origin: * to the response (which is what the browser plugin does) is not sufficient to grant that permission. (Preflighted requests require an explicit allowed origin in the response, not a wild card).

    评论

报告相同问题?

悬赏问题

  • ¥15 echarts动画效果失效的问题。官网下载的例子。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加