拒绝设置不安全标题“Cookie”用ajax调用Rest服务器 [英] Refused to set unsafe header "Cookie" with ajax call Rest server
问题描述
我在忙于构建一个Phonegap应用程序,与我的Drupal休息服务器(模块:服务)连接。
我的Drupal网站(PHP)有代码:header('Access-Control-Allow-Origin:*');
请使用以下代码连接到我的Rest服务器: http://pastebin.com/xfygQexn 我得到以下内容控制台讯息:拒绝设置不安全标题Cookie
代码: http ://pastebin.com/FNGgPQKv
错误:拒绝设置不安全标题Cookie
有人知道这个问题吗? p>
非常感谢。
我需要令牌和会话进行注销调用。
您尝试为单独的ajax调用设置Cookie,但 XMLHttpRequest规范。相反,你可以设置一个cookie到当前页面,浏览器会把它放在你的ajax请求if / path匹配,即使用 jquery.cookie 插件:
$。cookie('the_cookie','the_value' path:'/'});
Im busy building a Phonegap app that connects with my Drupal rest server (Module: Services). My Drupal website (PHP) has the code: header('Access-Control-Allow-Origin: *');
When I'm trying to connect to my Rest server with the following code: http://pastebin.com/xfygQexn I'm getting the following console message: Refused to set unsafe header "Cookie"
Code: http://pastebin.com/FNGgPQKv Error: Refused to set unsafe header "Cookie"
Is anyone familiar with this problem?
Many thanks.
Im needing the token and the session for a logout call.
You are trying to set cookies for separate ajax call but this is not allowed by XMLHttpRequest specification. Instead, you can set a cookie to the current page and browser will put it in your ajax request if domain/path matches, i.e. by using jquery.cookie plugin:
$.cookie('the_cookie', 'the_value', { path: '/' });
这篇关于拒绝设置不安全标题“Cookie”用ajax调用Rest服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!