I have a ExtJS grid with the following:
// Initialize the state manager
Ext.state.Manager.setProvider(new Ext.state.CookieProvider())开发者_开发问答;
// Set the state id
stateful:true,
stateId:'Vehicle-grid',
I was able to get the cookie on a normal HTTP request. When I try to send a jQuery ajax request though I don't see the cookie server-side. All I see is jsessionid.
What am I missing.
I can paste the whole code if necessary, but I was just wondering if I was missing something fundamental about how this all works.
Thanks, Ian
PS - On the back end I have this code (grails controller):
def allCookies = request.cookies;
for (c in allCookies) {
println "\n"+c.name+"\n";
}
I only get JSESSIONID printed.
You want to send an ajax request with ExtJS, not through jQuery. jQuery has no idea about ExtJS's stateful variables/objects inherently (they are two different javascript libraries), so the cookie would not be handled the way you expect it to. I'm assuming the normal HTTP request you mention was handled by ExtJS, which is why you saw the expected cookie behavior.
Here's an example of how to fire an ajax request with ExtJS:
// Basic request
Ext.Ajax.request({
url: 'foo.php',
success: someFn,
failure: otherFn,
headers: {
'my-header': 'foo'
},
params: { foo: 'bar' }
});
More info can be found in the API Documentation.
Looks like I figured it out.
I foolishly didn't realize that the cookie is only set after certain events on the grid are triggered and not upon initialization, has nothing to do with a regular request vs. an ajax request.
Thanks for you help anyway McStretch.
精彩评论