开发者

Temporarily saving textarea value

I am trying to create a comment form like a page I know has. You fill in a comment, select a network to log into, you go to the login page, and when it redirects you back, your textarea value is still filled in what you had. Everything is done, except for storing the value, because I can’t figure that out.

Can someone point me in the direction of what to do? I tried the jQu开发者_JS百科ery.data() function, but when I get redirected back, it’s empty.


I would either use a session variable or a cookie. You can simply import those three functions I've linked on quirksmode.


.data() only stores data for the duration that page exists; when the browser navigates away, it's lost, like all other JS state information.

Your solutions here are to either store the value in a cookie with this cookie plugin, or store it in a session variable server-side. I'd recommend you store it in a cookie in this case, which is easy enough with the plugin.


those values are stored periodically on the server session. you just need a to make an ajax request every2 mins or so that copies the value from your textfield to the server...


My first thoughts are to send you to the .post() function. You could send the text (textarea.getVal()) through as a variable in the function and it's easy enough to use the PHP $_POST variable to access it from the page you send it to, etc.


$('#yourTextareaElement').html()

That will return the value of it, and from there, you can save it as a cookie with PHP or Javascript, whichever you prefer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜