如何设置请求头为jqGrid的Ajax对象 [英] How to set request header to the ajax object for jqGrid
本文介绍了如何设置请求头为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 的事件处理程序:
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屋!
查看全文