带有 ExtJS 4 存储的 HTTP 标头

发布于 2024-12-14 14:08:09 字数 68 浏览 7 评论 0原文

我已经实例化了几家商店。但在某个时刻,我会在所有这些中添加一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

染火枫林 2024-12-21 14:08:09

假设您使用的是 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.

朦胧时间 2024-12-21 14:08:09

wombleton 提供的答案很接近,但关键是您必须在商店的代理上设置 headers 属性,而不是在商店本身上设置,例如:

Ext.StoreManager.lookup("MyStore").proxy.headers = { foo: "bar" }

下次加载商店时指定的标头将与请求一起发送。

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.:

Ext.StoreManager.lookup("MyStore").proxy.headers = { foo: "bar" }

The next time you load the store the specified headers will be sent with the request.

迎风吟唱 2024-12-21 14:08:09

不要注意您的标头未定义,那是因为代理的标头未初始化,默认标头处于连接状态,但是在构建请求时,您的代理(甚至隐式代理)标头将被考虑在内,所以你可以做这样的事情:

Ext.apply(myStore.proxy.headers, {headerName:headerValue});

亲切的问候

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:

Ext.apply(myStore.proxy.headers, {headerName:headerValue});

Kind regards

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文