Form data, refresh (F5) and retaining data

V

ViLco

Hi, I'm starting to use ajax in these days and I'm building a test web
application.
It will be based on javascript on the client side, asp pages and a
XML-consuming DLL on the server, where the DLL handles data acces,
calculations and such.

Now, imagine that I'm in a form where I asked for a certain record, the
request went to the server and the server rrepondend, javascript received
the XML from the server and deserialized it into the various <input ...>
tags, showing all data as expected. If I click F5, or the "refresh/reload"
button of the browser, my form refreshes to the state it was in when I first
reached it: any form data gets lost, the form lokks just like it was when I
first got there.

What are the preferred methods to retain the form data, in this scenario?
 
G

Giacomo Ritucci

Hi, I'm starting to use ajax in these days and I'm building a test web
application.
It will be based on javascript on the client side, asp pages and a
XML-consuming DLL on the server, where the DLL handles data acces,
calculations and such.

Now, imagine that I'm in a form where I asked for a certain record, the
request went to the server and the server rrepondend, javascript received
the XML from the server and deserialized it into the various<input ...>
tags, showing all data as expected. If I click F5, or the "refresh/reload"
button of the browser, my form refreshes to the state it was in when I first
reached it: any form data gets lost, the form lokks just like it was when I
first got there.

What are the preferred methods to retain the form data, in this scenario?

You could:

* craft a querystring-like hash fragment and save it in window.location.hash

* or use window.localStorage

then, when you load you form you can check these places for values. If
they are not there, ask your server.

Bye,
Giacomo
 
E

Evertjan.

ViLco wrote on 14 jul 2010 in comp.lang.javascript:
Hi, I'm starting to use ajax in these days and I'm building a test web
application.
It will be based on javascript on the client side, asp pages and a
XML-consuming DLL on the server, where the DLL handles data acces,
calculations and such.

Now, imagine that I'm in a form where I asked for a certain record,
the request went to the server and the server rrepondend, javascript
received the XML from the server and deserialized it into the various
<input ...> tags, showing all data as expected. If I click F5, or the
"refresh/reload" button of the browser, my form refreshes to the state
it was in when I first reached it: any form data gets lost, the form
lokks just like it was when I first got there.

What are the preferred methods to retain the form data, in this
scenario?

You would not want to use ajax,

Just use ASP-Javascript serverside code
to populate the <input>s on a per session base
when refreshing via form post.

<input value='<% = theName %>' name='theName'>

This is guaranteed cross-browser compatible.
 
V

ViLco

You would not want to use ajax,

Just use ASP-Javascript serverside code
to populate the <input>s on a per session base
when refreshing via form post.

<input value='<% = theName %>' name='theName'>

This is guaranteed cross-browser compatible.

Thanks both to you and Giacomo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top