答案提交加入超时处理

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,19 +32,18 @@ $(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,
data: {homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}
}).done(function(data){
tested = true; tested = true;
console.log(data); console.log(data);
if(data.index <=0){ if(data.index <=0){
data.index = $('.ProResultTop').length+1; data.index = $('.ProResultTop').length+1;
} }
if (typeof cb == 'function') {cb(data); return;} if (typeof cb == 'function') {cb(data); return;}
var html=bt('t:result-list',data); var html=bt('t:result-list',data);
$('.ProResult').prepend(html); $('.ProResult').prepend(html);
@ -54,8 +53,13 @@ $(function(){
$(".HomeWorkCon form").submit(); $(".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);