Reputation: 23615
i'm just using the JQuery validation plugin. i have the following spec: 'if the form isn't used in 10 seconds, give the user a warning, if he doesn't do anything, submit it anyway'
besides the timer etc. i have this code to submit the form:
timeoutId = setTimeout(function() {
$("#session_expired").val("true");
$("form:first").validate({
onsubmit: false
});
$("form:first").submit();
}, 10000);
what it does: it sets a certain hidden field value and then it submits the form. I've added the validate function to make sure it doesn't validate in this case. Bu you might have guessed it: it doesn't work.
Anyone any clue?
Michel
Upvotes: 0
Views: 1891
Reputation: 5221
Try using the DOM method directly instead of jQuery submit method for the submit:
Replace
$("form:first").submit();
with:
document.forms[0].submit();
My guess is that:
$("form:first").validate({ onsubmit: false });
only applies to when the form is submited by a submit button push.
Upvotes: 1
Reputation: 3074
I would remove each part of the function and then test it until I can find which part of the function is a failing. Also us firebug and console.log to trace what is happening within the function. e.g.
timeoutId = setTimeout(function() {
console.log('timeout')
}, 10000);
Upvotes: 0