我有一个MVC应用程序,包括电子学习材料和每门课程的相关调查。我的调查是为了点击下一个按钮而调用课程控制器和GoForward方法,就像在Course / GoForward中一样,它在所有浏览器中运行良好。然而,当尝试将其连接到我们的遗留软件时,在浏览器控件中向用户显示内容时,我无法在第二个问题上单击下一个,这似乎只是停滞不前。是否有任何阻止BrowserControl在我的课程控制器上调用POST操作的东西。这是第一个问题的第一个问题,并成功地显示我的问题出现的第二个问题。我的代码如下:
if (questionType == 'Multiple Choice') {
var multiChoice = document.getElementsByName("radio");
var hasAnswer = 0;
for (var i = 0; i < multiChoice.length; i++) {
//If the radio button is checked submit the answer
if (multiChoice[i].checked) {
hasAnswer = 1;
var id = multiChoice[i].id;
var splitID = id.split(" ");
var surveyID = $('#surveyID').text();
var questionID = splitID[0];
var answerID = splitID[1];
var comment = document.getElementById(questionID + " Comment");
if (comment != null) {
comment = comment.value;
}
var postData = {
'surveyID': surveyID,
'questionID': questionID,
'answerID': answerID,
'answerText': null,
'comment': comment,
'questionType': questionType
};
if (button == "Next") {
$.post('/Course/GoForward/', postData, function (data) {
$('#SurveyDiv').html(data);
});
}
if (button == "Previous") {
$.post('/Course/GoBackward/', postData, function (data) {
$('#SurveyDiv').html(data);
});
}
if (button == "Submit") {
$.post('/Course/SurveyComplete/', postData, function (data) {
$('#SurveyDiv').html(data);
//$('#surveyDiv').hide();
var surveyID = $('#surveyID').text();
var postData = {
'surveyID': surveyID
};
$.post('/Course/SurveyAnswers/', postData, function (data) {
});
});
}
}
//If there are no selected answers at the end of the for loop
if (i == multiChoice.length - 1 && hasAnswer == 0) {
//Check if the question requires an answer
if (requiresAnswer == 1) {
$('#validationNoAnswer').show();
}
//else submit empty answer
else {
var id = multiChoice[0].id;
var splitID = id.split(" ");
var surveyID = $('#surveyID').text();
var questionID = splitID[0];
var answerID = 0;
var comment = document.getElementById(questionID + " Comment");
if (comment != null) {
comment = comment.value;
}
var postData = {
'surveyID': surveyID,
'questionID': questionID,
'answerID': answerID,
'answerText': null,
'comment': comment,
'questionType': questionType
};
if (button == "Next") {
$.post('/Course/GoForward/', postData, function (data) {
$('#SurveyDiv').html(data);
});
}
if (button == "Previous") {
$.post('/Course/GoBackward/', postData, function (data) {
$('#SurveyDiv').html(data);
});
}
if (button == "Submit") {
$.post('/Course/SurveyComplete/', postData, function (data) {
$('#SurveyDiv').html(data);
//$('#surveyDiv').hide();
var surveyID = $('#surveyID').text();
var postData = {
'surveyID': surveyID
};
$.post('/Course/SurveyAnswers/', postData, function (data) {
});
});
}
}//
}//
}//
}