How to set request header to the ajax object for jqGrid How to set request header to the ajax object for jqGrid ajax ajax

How to set request header to the ajax object for jqGrid


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

loadBeforeSend: function(jqXHR) {    jqXHR.setRequestHeader("Authorization", 'Basic YWRtaW5AZGVmYXVsdC5jb206YWRTwa6=');}


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

$.ajaxSetup({    headers : {        'Authorization' : 'Basic YWRtaW5AZGVmYXVsdC5jb206YWRTwa6='    }});