tags:

views:

113

answers:

2

I'm looking to implement an incremental save as you go along using AJAX to post data back to the server.

I am leaning towards JQuery AJAX implementation, but whatever I use I'm wondering how this fits into a three tiered web architecture that uses object datasources.

In the case of incremental saves, do I just need to bypass the object datasource and call my objects directly in the AJAX method or is there a way to hook both up.

A: 

Without knowing what your model looks like, I can only assume that what you're doing is pushing blobs of binary data to the server and you don't want to push the entire blob back at once.

Without asking why - in this scenario you would want to do a basic "chunking" pattern where you take the data you're trying to save, split it into chunks. You send a chunk with a sequence number to the server and continue sending chunks asynchronously in whatever order you feel like. When the server has received all of the chunks (knowing this possibly by you already having sent a "chunk manifest" to the server), it can commit all those chunks to a database or disk or whatever.

If you are dealing with rows of data rather than chunks of binary data the pattern is still fairly similar. Regardless of your Ajax implementation library, the goal would be to determine how many rows you plan on sending back, set up some kind of progress bar that updates dynamically, and then continually invoke a method that submits one row of changed data. Each time you do that (successfully), you can then inch the progress bar forward and allow the user to remain fully aware of the progress of the long-running operation.

This pattern should work regardless of how you're storing your underlying objects.

Kevin Hoffman
A: 

Is it possible to just use an AJAX timer control, set it to execute every 30 seconds (or whatever), grab the data from your input fields, apply them to your ObjectDataSource parameters and call an Update or Insert depending on if it's new or old content?

domus.vita