我需要JSON ajax request从另一个域创建一个。在我认为我克服了跨域问题之后,这就是我坚持的地方:
我需要添加我的自定义“ myCustomHeader”标题 - 从 a 很容易server,但从client...
我们添加了它们
$.ajax({
type: 'POST',
data: put the results of your header request here,
url: 'http://server.com/service',
beforeSend: function (xhr) {
xhr.setRequestHeader('myCustomHeader', '1')
},
success: function(data) {
alert('success.');
}
});
这会生成一个preflight带有我想要的标题的标题,没有values(CSV),但它们不会出现在request本身的标题中(如 myCustomHeader=X)......