gpt4 book ai didi

jquery & 去 : how do you set a json header

转载 作者:数据小太阳 更新时间:2023-10-29 03:07:01 25 4
gpt4 key购买 nike

如何在查询中设置 json header 。我需要它成为服务器上的字符串吗?:

...
$.ajax({
url: '',
headers: {
"listkey":{"key1":"val1", "key2": "val2", "key3":"val3"}
},
dataType: 'json',
cache: false,
success: function(data) {
...

最佳答案

我相信这很简单,只需添加:

contentType: "application/json"

作为对象属性。请参阅 docs 中的 contentType 属性.

完整示例:

...
$.ajax({
url: '',
contentType: 'application/json',
headers: {
"listkey":{"key1":"val1", "key2": "val2", "key3":"val3"}
},
dataType: 'json',
cache: false,
success: function(data) {
...

关于jquery & 去 : how do you set a json header,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30102045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com