Lan*_*ard 46 ajax jquery header cross-domain
我试图用jQuery访问谷歌文档.这是我到目前为止所拥有的:
var token = "my-auth-token";
$.ajax({
url: "http://docs.google.com/feeds/documents/private/full?max-results=1&alt=json",
dataType: 'jsonp',
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "GoogleLogin auth=" + token);
},
success: function(data, textStatus, XMLHttpRequest) {
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
}
});
Run Code Online (Sandbox Code Playgroud)
如果我设置dataType为jsonp(来自使用jQuery创建跨域Ajax请求),它不允许我设置标头.如果我遗漏jsonp,我无法提出跨域请求.如果我使用jQuery.getJSON,我不能传入任何标题...
在制作跨域ajax请求时(在jQuery中)有没有办法定义自定义标头?