How to set request header to the ajax object for jqGrid

前端 未结 2 1151
不知归路
不知归路 2020-11-27 23:40

I have the need to set the \'Authorization\' request header to the httpXMLRequest. On the grid definition I have tried to set via ajaxGridOptions like the following:

相关标签:
2条回答
  • 2020-11-27 23:53

    Another option as of today is setting the header globally for all AJAX requests:

    $.ajaxSetup({
        headers : {
            'Authorization' : 'Basic YWRtaW5AZGVmYXVsdC5jb206YWRTwa6='
        }
    });
    
    0 讨论(0)
  • 2020-11-28 00:20

    You can use for example loadBeforeSend event handler of the jqGrid defined as the following:

    loadBeforeSend: function(jqXHR) {
        jqXHR.setRequestHeader("Authorization", 'Basic YWRtaW5AZGVmYXVsdC5jb206YWRTwa6=');
    }
    
    0 讨论(0)
提交回复
热议问题