Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在BrowserControl中调用控制器操作未按预期工作_Javascript_Jquery_Controller_Webbrowser Control - Fatal编程技术网

Javascript 在BrowserControl中调用控制器操作未按预期工作

Javascript 在BrowserControl中调用控制器操作未按预期工作,javascript,jquery,controller,webbrowser-control,Javascript,Jquery,Controller,Webbrowser Control,我有一个MVC应用程序,包括在线学习材料和每门课程的相关调查。我的调查是这样设计的,点击next按钮,它会调用Course controller和GoForward方法,就像Course/GoForward一样,在所有浏览器中都运行良好。然而,当试图将其连接到我们的传统软件时,在浏览器控件中向用户显示内容,我无法在第二个问题上单击“下一步”,这似乎只是在拖延。是否有任何东西可以阻止BrowserControl对我的课程控制器调用POST操作。这对第一个问题起作用,并成功显示出现问题的第二个问题。

我有一个MVC应用程序,包括在线学习材料和每门课程的相关调查。我的调查是这样设计的,点击next按钮,它会调用Course controller和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) {                                                
                            });
                        });
                    }
                }//
            }//
        }//
    }
if(questionType==“多项选择”){
var multiChoice=document.getElementsByName(“radio”);
var hasAnswer=0;
对于(变量i=0;i
最有可能的情况是,您的网页在基于
网络浏览器的应用程序中以IE7传统模式运行。查看更多详细信息。我已经在IE7中查看了它,它按预期运行。我的意思是,如果页面在IE和
WebBrowser
控件(任何版本)中的行为不同,您需要为您的
WebBrowser
应用程序添加。