Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.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
Jquery mobile jquery移动重定向未发生_Jquery Mobile - Fatal编程技术网

Jquery mobile jquery移动重定向未发生

Jquery mobile jquery移动重定向未发生,jquery-mobile,Jquery Mobile,我正在使用jQueryMobile创建一个ipad应用程序。我有以下代码: function coursesandmodules() { var companyDBName = "abc3"; var studentId = "2"; $.ajax({ type : "GET", url

我正在使用jQueryMobile创建一个ipad应用程序。我有以下代码:

function coursesandmodules()
            {
                var companyDBName = "abc3";
                var studentId = "2";
                $.ajax({
                       type : "GET",
                       url : "http://192.168.1.78:8087/teach/rest/student/getcoursesandmodules/" +  companyDBName + "/" + studentId ,
                       dataType : "json",
                       error: function(error) {
                       alert("ERROR");
                       },
                       success : function(data,text,xhqr) {

                       var divElement = "<div id='coursesandmodules' data-role='page'><header data-role='header'><h1>Courses and Modules</h1></header><ul data-role='listview'></ul></div>";
                       $('#loginpage').after(divElement);
                       var jsonobj = eval(data);
                       for (i in jsonobj) {
                       var stringArray =  separate(i);
                       var CTId = stringArray[0];
                       var CTName = stringArray[1];

                       var listDivider = "<li data-role='divider' data-theme='b'>" +  CTName + "</li>";
                       $('#coursesandmodules ul').append(listDivider);
                       for(j in jsonobj[i]) {
                       var myObj = JSON.stringify(jsonobj[i][j]);
                       var myJsonObj = eval('(' + myObj + ')');
                       for (h in myJsonObj) {
                       var moduleId = h;
                       var moduleName = myJsonObj[h];
                       var list = "<li><a href='#module"+ moduleId + "'>" +  moduleName + "</a></li>";
                       $('#coursesandmodules ul').append(list);
                       topics(moduleId, moduleName, companyDBName);
                       }
                       }
                       }
                       }
                       });
            }

            function topics(moduleId, moduleName, companyDBName)
            {
                var id = "module" + moduleId;
                var url = "http://192.168.1.78:8087/teach/rest/student/getmoduletopics/" +  companyDBName + "/" + moduleId;
                $.ajax({
                       type : "GET", 
                       url :  url,
                       dataType : "json",
                       error : function(error) {
                       alert("ERROR");
                       },
                       success : function(data,text,xhqr) {
                       var jsonobj = eval(data);
                       var modulePage = "<div id='" + id + "' data-role='page'><header data-role='header'><h1>" + moduleName + "</h1><a href='#coursesandmodules'>Back</a><a href='#' onclick='savemodule(" +  moduleId  + ")'>Save</a></header></div>";
                       $('#loginpage').after(modulePage);
                       for (i in jsonobj){
                       var stringArray =  separate(i);
                       var topicId = stringArray[0];
                       var topicName = stringArray[1];
                       var topicText = jsonobj[i];

                       var topicCollapsible = "<div data-role='collapsible'><h1>"  +  topicName + "</h1>" +  topicText +  "</div>";
                       $("#" +  id).append(topicCollapsible);
                       }
                       }

                       });

            }

            function separate(string) {
                var str = string.substring(1,(string.length - 1));
                var stringArray = str.split("=");
                return stringArray;
            }


            function submit() {

                var username = $("#username").val();
                var password = $("#password").val();

                var url = "http://192.168.1.78:8087/teach/rest/student/authenticate?username=" +  username + "&password="+ password;

                $.ajax({
                       type : "GET", 
                       url :  url,
                       dataType : "json",
                       error : function(error) {
                       navigator.notification.alert("Error connecting to webservice");
                       },
                       success : function(data,text,xhqr) {
                       if(data) {
                       var jsonobj = eval(data);

                       // student info
                       var currentModule = data.currentModule;
                       var studentId = data.studentId;
                       var studentUserId = data.studentUserId;
                       var companyDbName = data.companyDbName;
                       var studentName = data.studentName;
                       var userName =  data.userName;
                       var companyId = data.companyId;
                       //save data
                       $.mobile.changePage('#coursesandmodules'); 
                       }
                       else {
                       navigator.notification.alert("Incorrect username/password combination");
                       }

                       }

                       });

            }

我从ondevicerad()函数中删除了对cursesandmodules()的调用。重定向不起作用。它保留在登录页面上

在您的代码中,您只是简单地指向一个锚,文档中没有提到这一点:

以下是他们的例子:

    //transition to the "about us" page with a slideup transition
$.mobile.changePage( "about/us.html", { transition: "slideup"} );

//transition to the "search results" page, using data from a form with an id of "search"
$.mobile.changePage( "searchresults.php", {
    type: "post",
    data: $("form#search").serialize()
});

//transition to the "confirm" page with a "pop" transition without tracking it in history   
$.mobile.changePage( "../alerts/confirm.html", {
    transition: "pop",
    reverse: false,
    changeHash: false
});

你可以用锚。我有一个id为命名锚点的div和data role='page'。与上面的代码重定向工程。我的猜测是它不起作用,因为coursesandmodules div尚未创建。注意,在第一个方法中,一些元素被添加到dom中。因此,当我首先使用onDeviceReady调用该方法,然后提交表单时,重定向就起作用了。如果我从submit()调用它并将其从onDeviveReady中删除,它将不起作用
    //transition to the "about us" page with a slideup transition
$.mobile.changePage( "about/us.html", { transition: "slideup"} );

//transition to the "search results" page, using data from a form with an id of "search"
$.mobile.changePage( "searchresults.php", {
    type: "post",
    data: $("form#search").serialize()
});

//transition to the "confirm" page with a "pop" transition without tracking it in history   
$.mobile.changePage( "../alerts/confirm.html", {
    transition: "pop",
    reverse: false,
    changeHash: false
});