可Ajax响应设置一个cookie? [英] Can an AJAX response set a cookie?
本文介绍了可Ajax响应设置一个cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
能否Ajax响应设置一个cookie?如果没有,什么是我的替代解决方案?我应该使用Javascript或类似的设置呢?
Can an AJAX response set a cookie? If not, what is my alternative solution? Should I set it with Javascript or something similar?
推荐答案
是,您可以在服务器端code就像你做AJAX请求设置的cookie由于服务器正常请求不能正常请求或AJAX请求区分开来。
Yes, you can set cookie in the AJAX request in the server-side code just as you'd do for a normal request since the server cannot differentiate between a normal request or an AJAX request.
AJAX请求是请求服务器只是一种特殊的方式,服务器将需要在任何HTTP请求来响应。在您可以添加饼干请求的响应。
AJAX requests are just a special way of requesting to server, the server will need to respond back as in any HTTP request. In the response of the request you can add cookies.
这篇关于可Ajax响应设置一个cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文