【发布时间】:2011-04-01 20:43:59
【问题描述】:
我有问题:
1) 我尝试过使用 JsonP,但无法让 POST 工作。本质上,我正在尝试使用 API 进行身份验证,通过 HTTPS 在标头中传递 Base64 编码的名称值对。
2) 如何在标头中传递此键/值?任何帮助,将不胜感激!这是我想要的示例,尽管这显然行不通:
// where does this go?
var headerString = 'user=' + encodeURIComponent(username + ':' + password);
$.ajax({
type: "POST",
url: "https://anotherurl.on.another.server/LOGIN",
data: "I have no data, I'm logging in with header authentication",
dataType: "json",
success: function(data) {
},
error: function(data){
}
});
【问题讨论】:
-
jsonp 使用 GET 请求......它有点像黑客
-
我想知道为什么我会收到有趣的 console.log 错误。对“回调”有意义。
标签: javascript ajax jquery https