Cordova 使用ajax请求将sessionid作为头添加到带有framework7的POST请求中

Cordova 使用ajax请求将sessionid作为头添加到带有framework7的POST请求中,cordova,html-framework-7,Cordova,Html Framework 7,我需要用户的sessionid进行服务器端身份验证。所以需要在每个请求的头中发布Sessionid,这是非常必要的。我正在使用以下命令在标题中发布sessionId,但发生了一些错误 apiservice.getProfileDetails = function(data, callback){ // $.cookie("sessionid", $.jStorage.get("sessionKey")); document.cookie = "sessionid=" +$.jStorage.ge

我需要用户的sessionid进行服务器端身份验证。所以需要在每个请求的头中发布Sessionid,这是非常必要的。我正在使用以下命令在标题中发布sessionId,但发生了一些错误

apiservice.getProfileDetails = function(data, callback){
// $.cookie("sessionid", $.jStorage.get("sessionKey"));
document.cookie = "sessionid=" +$.jStorage.get("sessionKey");
console.log(document.cookie);
var requestEnvelope = {
    url: apiservice.baseUrl + '/get/my/information/?callback='+callback,
    xhrFields: {withCredentials: true},
    crossDomain: true,
    async: false,
    type: 'POST',
    // beforeSend : function(xhr) { var cookie = credentials["COOKIE"]; console.info( "adding cookie: "+ $.jStorage.get("sessionKey") ); xhr.setRequestHeader('Cookie', $.jStorage.get("sessionKey")); },
    beforeSend: function (request)
            {
            request.setRequestHeader("Cookie", "sessionid=" +$.jStorage.get("sessionKey"));
            },
    // setCookies: $.jStorage.get("sessionKey"), 
    // headers: {"sessionid": $.jStorage.get("sessionKey")},
    data: JSON.stringify(data),
    complete: function(res){
            ux.getProfileDetails(res.responseText);
    }
   }
    $.ajax(requestEnvelope);
};
出现的错误是
jquery.min.js:4拒绝设置不安全的标题“Cookie”

还尝试在标头中设置Cookie

headers: {"sessionid": $.jStorage.get("sessionKey")},

但同样的错误,任何解决方案

我在一个使用framework7的项目中工作,我发现使用framework7的$$有两种方法

1) 将此设置为在每次ajax之前执行

var $$ = Dom7;

$$(document).on('ajaxStart', function(e){
   var xhr = e.detail.xhr;
   xhr.setRequestHeader('token', 'value');
});
(二)


请参阅ajax中的headers参数。

我在一个使用framework7的项目中工作,我发现使用framework7的$$有两种方法

1) 将此设置为在每次ajax之前执行

var $$ = Dom7;

$$(document).on('ajaxStart', function(e){
   var xhr = e.detail.xhr;
   xhr.setRequestHeader('token', 'value');
});
(二)

请参见ajax中的headers参数