我有以下函数应该将 JSON 值传递给外部 API:
ack_receipt();
function ack_receipt() {
var app_name = "Test Trial Account for infobip";
$.ajax({
url: "http://api.infobip.com/2fa/1/applications",
async: true,
crossDomain: true,
headers: {
"authorization": "Basic xxxxxxxxxxxxxxx",
"cache-control": "no-cache"
},
type: 'POST',
dataType: 'JSON',
data: {
"name": app_name
},
success: function(data, status) {
console.log(status);
},
error: function(x, status, error) {
console.log(x, status, error);
if (x.status == 403) {
swal("Sorry, your session has expired. Please login again to continue");
} else if (x.status == 404) {
swal("Sorry, something went wrong from our side");
} else {
console.error("An error occurred: " + status + "nError: " + error);
}
}
});
}
但是,当我尝试从浏览器运行该功能时,我收到以下警告,并且脚本在途中失败:
本网站使用 SHA-1 证书;建议您使用具有比 SHA-1 更强的哈希函数的签名算法的证书。
跨域请求被阻止:同源策略不允许在https://api.infobip.com/2fa/1/applications读取远程资源。(原因:CORS 预检通道的 CORS 标头“Access-Control-Allow-Headers”中缺少令牌“缓存控制”)。
请就如何处理帖子和Cache-control
.