HTTP Headers with ExtJS 4 Stores

蓝咒 提交于 2019-12-09 16:43:34

问题


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 ?


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/8045917/http-headers-with-extjs-4-stores

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!