I'm trying to use ajaxsubmit in conjunction with a JavaScript setTimeout() statement to case a form to do an ajax submit every 60 seconds, much the way GMail auto-saves your drafts in progress.
In my own module, I added the following JavaScript:
$(document).ready(function(){ 'setTimeout("$('#my-form-id').submit()", 60000)' });
The ajax progress bar pops up after 60 seconds as expected, but the returned value is:
"An error occurred:
Unspecified error"
I'm having a heck of a time debugging what might be missing or going wrong. It looks like the server's response, returned through Drupal.parseJson, is an empty string, but I'm getting lost as I try to trace the problem further back through JSTools' Drupal.redirectFormSubmit(). I've also tried unsuccessfully to use jQuery to trigger the Submit button click event. I feel like I'm probably missing some small but important step, but I haven't been able to figure out what it is. I appreciate any tips or suggestions anyone might have!
Thanks,
-Andy
Comments
Comment #1
usonian commented(Updated title to reflect the real question; if there's a procedure that will work in a setTimeout(), it should work pretty much anywhere)
Comment #2
usonian commentedFinally, I answered my own question.
It seems that the DOM manipulation that attaches the ajaxsubmit logic to the form's onsubmit() event relies on the actual form button being clicked, not the form's submit() being triggered. This JS code does exactly what I need, saving the form via AJAX every sixty seconds.
(Interestingly,
$('#edit-submit').click()did not work, which is why I resorted to document.getElementById(). )Comment #3
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.