zoukankan      html  css  js  c++  java
  • ajax 初始化请求前携带参数


     $(function () {
        function SetAjax(wxOpenId, departCode) {
            $.ajaxSetup({
                xhrFields: {
                    withCredentials: true
                },
                beforeSend: function (o) {
                    if (wxOpenId && departCode) {
                        o.setRequestHeader('wxOpenId', " " + wxOpenId);
                        o.setRequestHeader('DepartCode', " " + departCode);
                    }
                }
            });
        }

        var wxOpenId = App.GetQueryStringByName("wxOpenId");
        var DepartCode = App.GetQueryStringByName("DepartCode");

        if (!wxOpenId) {
            wxOpenId = App.GetCookie("wxOpenId");
        } else {
            App.SetCookie("wxOpenId", wxOpenId, 365);
        }

        if (!DepartCode) {
            DepartCode = App.GetCookie("DepartCode");
        } else {
            App.SetCookie("DepartCode", DepartCode, 365);
        }

        if (wxOpenId && departCode){
            SetAjax(wxOpenId, departCode);
        }
    });
  • 相关阅读:
    uva 11997 K Smallest Sums
    uvalive 3135 Argus
    React-Redux填坑
    fetch方法
    react 学习前期用到的插件
    Redux:with React(一)
    Redux:data flow
    Redux:store
    Redux:Reducers
    Redux:action
  • 原文地址:https://www.cnblogs.com/whaozl/p/4507552.html
Copyright © 2011-2022 走看看