如何将请求标头设置为 jqGrid 的 ajax 对象 [英] How to set request header to the ajax object for jqGrid

查看:36
本文介绍了如何将请求标头设置为 jqGrid 的 ajax 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将授权"请求标头设置为 httpXMLRequest.在网格定义上,我尝试通过 ajaxGridOptions 进行设置,如下所示:

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:

 ajaxGridOptions: { Authorization: 'Basic YWRtaW5AZGVmYXVsdC5jb206YWRTwa6=' } 

并使用如下的 beforeSend 事件:

and use the beforeSend event like the following:

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

以上都不适合我.什么是正确的语法?

None of above works for me. What's the right syntax?

谢谢!!

推荐答案

你可以使用例如 loadBeforeSend jqGrid 的事件处理函数定义如下:

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

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

这篇关于如何将请求标头设置为 jqGrid 的 ajax 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆