我想使用 json 数据进行重定向并具有 header ,我尝试过 jquery.redirect 但我不知道如何放置 header (如 'content-type': 'application/json')...
这是我的代码:
$.redirect('url', data, 'POST', '_blank');
有什么建议吗?
最佳答案
你不能。
使用浏览器端 JavaScript 时,唯一可以指定 HTTP 请求 header 的情况是使用 fetch
或 XMLHttpRequest
(即 Ajax)时。
(您还可以在表单提交中使用 enctype
,但不能使用 application/json
作为值)。
关于javascript - 使用 Post 数据 (json) 重定向并具有 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55449543/