我有这个代码向维基百科API发送请求(记录为here)但是当我查看Chromium中的网络标签时,标题Api-User-Agent
没有发送,为什么?
$.ajax({
url: "https://en.wikipedia.org/w/api.php?",
data: {
action: 'query',
prop:'revisions',
rvprop: 'content',
format:'json',
titles: 'Hacker_culture'
},
headers: {
'Api-User-Agent': 'Example Agent'
},
dataType: 'jsonp',
success: function(data) {
}
});
答案 0 :(得分:2)
您无法以与为其使用POST相同的方式在jsonp请求中发送标头。他们不是XmlHttpRequest,而是脚本请求。