grails - setting cookies when render type is "contentType: text/json" -
Is the return render type set as json when it is possible to set cookies on the reaction?
I can set cookies on a standard reader type and later on the response object, I am able to get it back on later request. However, if I had to set cookies while presenting return values as Jason, then I could not return the cookie on the next request object. What's going on here
These two actions work, as do the required work with the 'basic form', post after taking a regular action, with 'Regular submit', when users click submit Does.
// Sets the first action cookie and the second action is basically set cookie def regular action = {// cookie plugin response. Uses a set cookie ("username-regular", "regular cocky user 123", 604800); Submit Return (See: "Basic Farm"); } // REGURI with form post DRF with name == {def myCookie = request.getCookie ("username-regular"); // value presents 'regularCookieUser123' returns (see: "result view"); }
When I switch to setting cookies before returning with a response with json, I do not get the cookies back with the post.
The request begins with receiving an HTML document that contains a form and when the doctor's load event is removed, the following request is attached with javascript in JavaScript like this: < / P>
var SomeUrl = "http: // localhost / jason action"; $ Get (someUrl, functions (jsonData) {// do some work with Javascript}
Controller's work:
// asked this verb Returns a html doc with a form initially and def loadJsonForm = {return render (see: "jsonform") //} is called by javascript when the document load event def jsonAction = {response.setCookie (" User-type: 'text / json') {'pair' ('myKey': "someValue")}}} / def myCookie = request .getCookie ("Uses Yes name-JS "); // zero value is found, expected: submit the user's return to jsoncookie (see:" result view ");}
data returned As a result of the user pressing the 'submit' button, not through the server and the script. Before presenting with both 'Regular submit' and 'JasonSubmit', I look at the cookies stored in the browser (Firefox), so I know that is, they Accessed clients.
I realized what's the problem - a path not set for the cookie plugin cookie , So it is stored with "server / controller / action" later on request when I'm asking for cookies, the plugin returns the cookies associated with the new request path.
Refresh plugin code so that cookies are stored in similar paths.
Comments
Post a Comment