I have the following function:
function mark_unmark_user_answer(targ, answer, answer_id, test_id, test_type, question_no, module_url) {
if(checked==targ){
targ.checked=false;
checked=false;
} else {
checked=targ;
}
$.post(module_url, {'test_id':test_id, 'question_no':question_no, 'op':'mark_ans', 'test_type':test_type, 'answer_no':answer, 'answer_id':answer_id}, function(data) {
if(jQuery.trim(data)=='unmark_ans') {
$('input[type="radio"]').removeAttr('checked');
$('#display_'+question_no).removeClass('green');
$('#display_'+question_no).removeClass('blue');
$('#display_'+question_no).addClass('orange');
} else {
//$('#mark_review').val('Mark');
$('#display_'+question_no).removeClass('orange');
$('#display_'+question_no).removeClass('blue');
$('#display_'+question_no).addClass("green");
$('#mark_review').attr('disabled', false);
}
var total_questions = $('#total_questions').val();
test_question_attempted_count( total_questions );
});
}
I want to set a timeout of 30 seconds for this function. Therefore, if the response to the ajax request is not received within 30 seconds, then a warning message will appear with the message that "your Internet connection has some problems." Otherwise, a normal function must be performed.
Can anyone help with this?
Thanks in advance.
source
share