https ajax cross,javascript - Cross Domain AJAX POST / HTTPS / Header Authentication? - Stack Overfl...

博主在尝试使用JSONP进行POST请求以通过Header进行身份验证,但遇到了困难。他们希望将Base64编码的用户名和密码作为Header发送到HTTPS API,但无法使其工作。示例代码显示了尝试的方法,尽管这是无效的。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I have to issues:

1) I've tried using JsonP, but can't get POSTing to work. Essentially, I'm trying to authenticate with an API, passing a Base64-encoded namevaluepair in the header over HTTPS.

2) How do I pass this key/value in the header? Any help would be appreciated! Here is an example of what I want, though this obviously doesn't work:

// 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){

}

});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值