Connecting Tech Pros Worldwide Help | Site Map

Ajax Form Save-Reload

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 7th, 2008, 05:25 PM
MC
Guest
 
Posts: n/a
Default Ajax Form Save-Reload

Hi,

I am googling for a script and can't seem to find code to do this. I can
probably write code to save but reloading is an issue.

I want to, using ajax, send all form data back to a server and store. A
concise function to cycle through the fields and create a [element
name,value][element name,value] string would be great. I can give the user
the button to call this "Save Form Data" and store in on the server.

I want to give the user a button, and using ajax call to the server and get
the data. This I can do. Given a string of data, reload the fields in the
form. Cycling through the data, finding the matching element name, and
reload the value given the appropriate element type, text, checkbox, radio,
select.

I know this exists but have been unable to find.
Thanks,
Mica



  #2  
Old March 8th, 2008, 10:25 PM
MC
Guest
 
Posts: n/a
Default Re: Ajax Form Save-Reload

I separated getting the form data and serializing it from the ajax send.
I have a server side mechanism built to store and retrieve the data.
I am currently working on a reload function. Its pretty close to done
although its taken about 12 hours.

I also would not use the YUI as it is much heavier code than I like.

MC


  #3  
Old March 9th, 2008, 04:15 AM
dhtml
Guest
 
Posts: n/a
Default Re: Ajax Form Save-Reload

On Mar 8, 3:15 pm, "MC" <mica[removethis]@aisus.comwrote:
Quote:
I separated getting the form data and serializing it from the ajax send.
I have a server side mechanism built to store and retrieve the data.
I am currently working on a reload function. Its pretty close to done
although its taken about 12 hours.
>
That's not bad at all - 12 hours. These things are not as easy as they
might seem.

Do you have unit tests for it? If not, it would help when it comes
time to change things.

There might be cases like checkbox, select-multiple, or BUTTON
elements (IE has problems here), that require patches.

Unit tests make continual improvement easier. You can make a change
and get either a "green" or a "red".

I like YUI Test. I think it is easier to use than JSUnit. The author
is committed to it and fixed the bugs I filed pretty quickly.

Quote:
I also would not use the YUI as it is much heavier code than I like.
>
MC
  #4  
Old March 9th, 2008, 04:55 PM
MC
Guest
 
Posts: n/a
Default Re: Ajax Form Save-Reload

Ok,
Got it all working...now at 20 hours. Ran into an issue with the javascript
tho. The returned data to populate into the form looks like

"\n\n\n\n\n\n\nMyDataIsHere\n"

Any ideas? I had to delete the \n out to get it to parse correctly. Code is
below.
MC

var FormData = "";
function handleResponse() {
if(http.readyState == 4){
formData = http.responseText;
formData = formData.replace(/\r|\n|\r\n/g, "");
}
}


  #5  
Old March 10th, 2008, 07:05 AM
dhtml
Guest
 
Posts: n/a
Default Re: Ajax Form Save-Reload

On Mar 9, 9:49 am, "MC" <mica[removethis]@aisus.comwrote:
Quote:
Ok,
Got it all working...now at 20 hours. Ran into an issue with the javascript
tho. The returned data to populate into the form looks like
>
"\n\n\n\n\n\n\nMyDataIsHere\n"
>
Any ideas? I had to delete the \n out to get it to parse correctly. Code is
below.
The server is apparently sending some \r\n back in the response.

It appears that this function will not work quite right with a
TEXTAREA, which can contain newlines.

Check the data before it goes to the server and see if it has
newlines. You could write a roundtrip() function to verify garbageIn
== garbageOut. If it doesn't, the newlines are being added on the
server.

Quote:
MC
>
var FormData = "";
function handleResponse() {
if(http.readyState == 4){
formData = http.responseText;
formData = formData.replace(/\r|\n|\r\n/g, "");
}
>
}
  #6  
Old March 10th, 2008, 09:15 PM
MC
Guest
 
Posts: n/a
Default Re: Ajax Form Save-Reload

The data hitting the server is correct.
The data coming out of the database is correct.
The data leaving the app server is correct.
I am using Apache 2.0.59 for testing. I have no idea inside or after it
leaves Apache.

"dhtml" <dhtmlkitchen@gmail.comwrote in message
news:926e0dad-6f1a-4b3f-9e1b-19b24d699ef6@s37g2000prg.googlegroups.com...
Quote:
On Mar 9, 9:49 am, "MC" <mica[removethis]@aisus.comwrote:
Quote:
>Ok,
>Got it all working...now at 20 hours. Ran into an issue with the
>javascript
>tho. The returned data to populate into the form looks like
>>
>"\n\n\n\n\n\n\nMyDataIsHere\n"
>>
>Any ideas? I had to delete the \n out to get it to parse correctly. Code
>is
>below.
>
The server is apparently sending some \r\n back in the response.
>
It appears that this function will not work quite right with a
TEXTAREA, which can contain newlines.
>
Check the data before it goes to the server and see if it has
newlines. You could write a roundtrip() function to verify garbageIn
== garbageOut. If it doesn't, the newlines are being added on the
server.
>
>
Quote:
>MC
>>
>var FormData = "";
>function handleResponse() {
> if(http.readyState == 4){
> formData = http.responseText;
> formData = formData.replace(/\r|\n|\r\n/g, "");
> }
>>
>}
>

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.