答案提交加入超时处理

This commit is contained in:
guange 2016-03-18 15:40:02 +08:00
parent 45c51ef8db
commit b356c6cd1f
1 changed files with 25 additions and 21 deletions

View File

@ -32,30 +32,34 @@ $(function(){
return; return;
} }
$.post( $.ajax({
'/student_work/program_test', url: '/student_work/program_test',
{homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}, type: 'POST',
function(data,status){ timeout: 60*1000,
tested = true; data: {homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}
console.log(data); }).done(function(data){
if(data.index <=0){ tested = true;
data.index = $('.ProResultTop').length+1; console.log(data);
} if(data.index <=0){
data.index = $('.ProResultTop').length+1;
}
if (typeof cb == 'function') {cb(data); return;}
var html=bt('t:result-list',data);
$('.ProResult').prepend(html);
if (typeof cb == 'function') {cb(data); return;} if (data.status==0 && is_test != 'true') {
var r=confirm("答题正确,是否立刻提交?");
if (r) {
var html=bt('t:result-list',data); $(".HomeWorkCon form").submit();
$('.ProResult').prepend(html);
if (data.status==0 && is_test != 'true') {
var r=confirm("答题正确,是否立刻提交?");
if (r) {
$(".HomeWorkCon form").submit();
}
} }
} }
); }).fail(function(xhr, status){
if(status == 'timeout'){
alert("您的答案超时了, 请检查代码是否存在死循环的错误.");
} else {
alert("测试失败,服务器出错.")
}
});
}; };
$('#test-program-btn').on('click', test_program); $('#test-program-btn').on('click', test_program);