Dan,
I'm using the form plugin to do an autosave. Here are some chunks of
what I do (it's not namespaced, so you might want to add that, etc):
var _timerRunning = false;
var _timer = null;
function startTimer()
{
if (! _timerRunning)
{
_timer = setTimeout ( "save()", 12000 );
_timerRunning = true;
}
}
$(document).ready(function() {
startTimer();
});
function save(successFn)
{
var options = {
type: 'POST',
beforeSubmit: beginRequest,
success: (successFn != undefined) ? successFn :
handleResponse,
semantic: true
};
$("#surveyForm").ajaxSubmit(options);
}
You can optionally pass success/callback function into save(), ie: save(
onSuccess ). In my case, it was OK for it to post to the url declared in
the form tag, but there's a url option you can set in the form plugin,
too. Not shown above: I also have a hidden name="action" element that I
change the value of at different times, based on button clicks (if the
user causes a save), to support different handling on the post to the
server.
- Jack
Dan Wilson wrote:
> I am attempting to use the .serialize function to post a form via
> Ajax. The form is very large and has just about every type of form
> element possible. I was not clear on the semantics to select all form
> elements in a particular form and all the examples I found were for
> [EMAIL PROTECTED]
>
> The use case is an autosave for the form. I looked at the form plugin
> and it seemed to want to take control of the form submit. In my use
> case I want to save the form in the background and let the user
> continue to work with the form.
>
>
> All help and advice is appreciated.
>
> dw
>
>
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/