普通的Ajax请求很遗憾不能返回服务器端设置的cookie

如何实现不刷新页面返回服务器设置的Cookie呢?

可以使用<script>或者<image>的src属性发起一个请求。

var script = document.getElementById('scriptA');
script.setAttribute('src', url);

url里设置的cookie会返回到浏览器

也可以在返回的JS代码中调用函数,例如成功调用成功函数,失败调用失败代码。也就是JSONP。

相关文章:

  • 2022-02-01
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2022-03-01
猜你喜欢
  • 2021-12-19
  • 2021-12-19
  • 2022-01-02
  • 2021-09-02
  • 2021-10-15
  • 2021-12-21
  • 2021-09-15
相关资源
相似解决方案