473,322 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Ajax Form Save-Reload

MC
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
Mar 7 '08 #1
5 2244
MC
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
Mar 8 '08 #2
On Mar 8, 3:15 pm, "MC" <mica[removethis]@aisus.comwrote:
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.

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

MC
Mar 9 '08 #3
MC
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, "");
}
}
Mar 9 '08 #4
On Mar 9, 9:49 am, "MC" <mica[removethis]@aisus.comwrote:
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.

MC

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

}
Mar 10 '08 #5
MC
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" <dh**********@gmail.comwrote in message
news:92**********************************@s37g2000 prg.googlegroups.com...
On Mar 9, 9:49 am, "MC" <mica[removethis]@aisus.comwrote:
>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.

>MC

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

}

Mar 10 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: C Watson | last post by:
Hi, I'm wondering if anyone can help me with AJAX in ASP.NET 1.1. I have a very specific feature that I would like to use it for. I have a rather long form that the users use to enter data...
31
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked...
2
by: nick | last post by:
Hi I have a web form sitting inside a desktop application written in Delphi (rendered by its browser component based on IE engine). The form runs in 2 modes: - live mode: all data freshly...
1
by: John Chan | last post by:
Hi, Im doing a maintenance application in ajax and coldfusion at work on IE6 exclusively. I have a save button on each form and i have to do various validations server side and on client side...
5
by: KingdomHeart | last post by:
I am very newbie in ajax, so please forgive me if my question are so dump. I want to create a box where user can type a message and when they click "Save" button. That text will be save. I got the...
7
xNephilimx
by: xNephilimx | last post by:
lHi guys! I'm having a little problem that's getting on my nerves, I couldn't find a solution, I also tryed googling it and I found nothing... (my field of expertise is in AS 2 and 3, but I still...
3
by: arggg | last post by:
I have a form in PHP that needs to be processed by the same page. I have ajax calling the page and parsing the data however I cannot get the POST data to be sent via AJAX to the PHP Page. I found...
17
by: Shalini Bhalla | last post by:
i have 2 tables bank master and branch details having bankcode as a common feild . i have designed a form in which i am filtering branches according to a particular bank code using ajax ,...
8
omerbutt
by: omerbutt | last post by:
hi there i have a form with multiple input (type/text ) fields and three inputs(type/file) fields i have to submit the form via ajax because i have multiple forms on this page ,you can say it is a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.