I have the following action:
$('.sub_outworker').live('click', function() {
var input = $(this);
var current_div = input.parents('div.report');
var current_div_id = current_div.attr('id');
var replace_div = current_div.children('div').first();
var submission = submit_form(input, replace_div);
var i = 0;
}
The submit_form() function looks like this:
function submit_form(input, replace_div) {
var form = input.parents('form');
loading_gif(replace_div);
$.ajax({
type: 'POST',
url: form.attr('action'),
data: 'ajax=true&' + form.serialize(),
success: function(data) {
get_json();
if(data == 'success') {
return 'success';
}
else {
return 'failed';
}
}
});
}
I want to check whether submission == failed and if it does run submit_form again (ie. give the function a second chance to work - mainly because it occasionally fails validation due to a mismatch in tokens). I'm not sure how to go about this though!
successcallback.submit_formdoes not return anything.