加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

SAPUI5内置的AJAX类库对POST请求的处理不提交HTTP HEADERS

发布时间:2020-12-16 01:31:05 所属栏目:百科 来源:网络整理
导读:SAPUI5内置的AJAX类库,在提交POST请求的时候,忽略了http headers。GET请求没有这个问题。 下面的代码不能提交HTTP Headers sUrl = getSMPURL() + "/odata/applications/latest/com.sap.flight.kapsel/Connections";$.ajax({ type : "POST",cache : false,u

SAPUI5内置的AJAX类库,在提交POST请求的时候,忽略了http headers。GET请求没有这个问题。

下面的代码不能提交HTTP Headers

sUrl = getSMPURL() + "/odata/applications/latest/com.sap.flight.kapsel/Connections";
$.ajax({
    type : "POST",cache : false,url: sUrl,data: payload,beforeSend : function(request) {
        request.setRequestHeader('Content-Type',"application/xml");
    },success : function(data,ajaxOptions,xhr) {
        alert("passed register");
    },error : function(xhr,thrownError) {
        alert("shit");
    },xhrFields : {
        withCredentials : true,}
});
下面的代码可以提交HTTP Headers

这里写代码片
sUrl = getSMPURL() + “/odata/applications/latest/com.sap.flight.kapsel”;
$.ajax({
headers: {
‘Authorization’: “Basic ” + btoa(getUserName() + “:” + getPassword())
},
type : “GET”,
cache : false,
url: sUrl,
dataType:’xml’,
beforeSend : function(request) {

},xhr) {
        alert("passed authentication");
    },}
});

“`

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读