zoukankan      html  css  js  c++  java
  • ajax跨域请求带cookie

    调用网站:a.xxx.com

    jQuery(document).ready(function () {
    $.ajax({
    type: "get",
    async: true,
    url: "http://www.xxx.com/common/Index", //跨域请求的URL
    dataType: "html",
    xhrFields: {
    withCredentials: true
    },
    crossDomain: true,

    success: function (json) {

    $("#header").html(json);
    }
    });
    });

    服务端网站:

    web.config需要配置

    <system.webServer>
    <modules>
    <remove name="FormsAuthenticationModule" />
    </modules>
    <httpProtocol>
    <customHeaders>
    <add name="Access-Control-Allow-Origin" value="http://a.xxx.com" />
    <add name="Access-Control-Allow-Credentials" value="true" />
    <add name="Access-Control-Allow-Headers" value="Content-Type" />
    <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />
    </customHeaders>

    </httpProtocol>
    </system.webServer>

  • 相关阅读:
    HttpWatch 有火狐版本?
    JQgrid的最新API
    jqgrid
    JSON的学习网站
    array创建数组
    Numpy安装及测试
    SQLite3删除数据_7
    SQLite3修改数据_6
    SQLite3查询一条数据_5
    SQLite3查询所有数据_4
  • 原文地址:https://www.cnblogs.com/hwisecn/p/4993739.html
Copyright © 2011-2022 走看看