带有 ExtJS 4 存储的 HTTP 标头
我已经实例化了几家商店。但在某个时刻,我会在所有这些中添加一个 HTTP 标头。我怎样才能用 ExtJS 4 做到这一点?
I have already a few stores instanciated. But at a certain point, I'd to add a HTTP header in all of them. How can I do that, with ExtJS 4 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(3)
假设您使用的是 ajax 代理,您可以更新
headers
相关商店的属性。查看代码,它将应用其中的任何内容作为标题。更复杂的解决方案将涉及重写 doRequest 函数来执行适合您的任何操作。
Assuming that you are using an ajax proxy, you could update the
headers
property on the stores in question. Looking at the code it'll apply whatever is in there as the headers.A more involved solution would involve overriding the
doRequest
function to do whatever suited you.wombleton 提供的答案很接近,但关键是您必须在商店的代理上设置 headers 属性,而不是在商店本身上设置,例如:
下次加载商店时指定的标头将与请求一起发送。
The answer provided by wombleton is close, but the key is that you have to set the headers property on the store's proxy, not on the store itself, e.g.:
The next time you load the store the specified headers will be sent with the request.
不要注意您的标头未定义,那是因为代理的标头未初始化,默认标头处于连接状态,但是在构建请求时,您的代理(甚至隐式代理)标头将被考虑在内,所以你可以做这样的事情:
亲切的问候
Don't pay attention to your headers being undefined, thats because the proxy has headers uninitialized, the default headers are in connection, but, at the time of building the request, your proxy (even implicit proxys) headers, wil be taken into acount, so you can do something like this:
Kind regards