views:

218

answers:

2

My application has a lot of decision to make before finally saving my data to the database. I am using JQuery to do this. I have succeeded in creating a moderately long xml string, due to the fact that the user will enter data that will each need to be verified.

I have made this decision base of the number of trips i expect my application to make back to the server. Currently i'm storing this xml in a hidden field. I want to know if there are better approaches? Please.

A: 

Are you passing the hidden field along through multiple form submissions? If that's the case, you should probably look into storing session variables. This really is a lot more reliable (and better practice) than keeping it all client-side.

Make sure you're still verifying the data server-side. Don't trust javascript alone to do it.

keithjgrant
Im verifying it both side. Some controls are plain html while others are asp server controls. Can i use JQuery with session variables?
Colour Blend
Session variables are handled by your server script, but their values can always be passed back into jQuery using JSON encoding. How much control/access do you have to the server script here (and what language is it?)
keithjgrant
Oh, hello, ASP. Check out http://www.w3schools.com/ASP/asp_sessions.asp and see if that's a workable approach.
keithjgrant
I can use sessions. I guess the missing ingredient here is JSON. I better start learning.
Colour Blend
A: 

You can use the 'data' function in jQuery:

http://docs.jquery.com/Core/data#namevalue

You can store name value pairs and retrieve them when you need them.

matpol
The data has dependencies, i dont think the jquery data function will do.
Colour Blend
It's basically what you are doing already. My process would be to keep the data somewhere as name value pairs then construct the xml string at the last minute when the the form/app what ever is read for sending. I do agree with the people above though that JSON is a better way of doing this as you can then store the data as an object. I also agree that you need to be wary of losing the data half way through the process by either sending the data as it is added using a kind of inline validation or using the techniques mnetioned above which I don't know anything about
matpol