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

     
    function ajaxPostRequestCipherMachine(url, param) {
            var url = url;
            var dict = {
                'ret' : false,
                'errmsg' : '请求失败'
            };
            var jsonData = param;
            $.ajax({
                type : "POST",
                url : url,
                async : false,
                data : jsonData,
                dataType : 'json',
                timeout : 10000,
                crossDomain:true, //设置跨域为true
                xhrFields: {
                    withCredentials: true //默认情况下,标准的跨域请求是不会发送cookie的
                },
                success : function(obj) {
                    dict = obj;
                },
                error : function(data) {
                    alert(JSON.stringify(data));
                }
            });
            return dict;
        }

    其中:

    crossDomain:true, //设置跨域为true
    xhrFields: {
         withCredentials: true //默认情况下,标准的跨域请求是不会发送cookie的
    }

    为要点

  • 相关阅读:
    Linux network driver
    Linux dd
    Linux aclocal
    Ubuntu
    Makefile
    控制导出符号
    Apache
    Linux nm命令
    Git Submodule
    Linux sed
  • 原文地址:https://www.cnblogs.com/samve/p/10371993.html
Copyright © 2011-2022 走看看