导航页面后数据不显示 [英] Data does not display after navigate page

查看:101
本文介绍了导航页面后数据不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题.我有一个调查表,在此表中,我还使用了ajax来调用某些数据.当用户单击取消"时,我希望它导航到其他页面,在其中使用ajax在listview中显示数据列表.对于单击和导航部分,我已经成功将其带到所需的页面,但是问题是,它不再显示数据列表.我使用与其他页面相同的方式,但是为此我无法获得任何帮助?我已经遍历了我的代码几次,但我无法理解是什么使它出错了.这是我的网页调查表单的代码:

i'm having problem. i have a survey form, in this form i used also the ajax to call some of the data. when user click cancel, i want it to navigate to other page where it display the list of data in listview using ajax. for the clicking and navigation part, i've succeed to bring it to the page that i want, but the problem is, it does not display anymore the list of data. I used the same way as i did for other page but for this i can't get..any help? i've gone through my code several times but i can't get what makes it wrong. this is my code for the page survey form:

$('#MrateCourse').live('pageinit', function(){

    var rowInput = "1";
    var pageInput = "1";
    var idInput = "${courseId}";
    var regNoInput = "${regNo}";

    $.ajax({
        url: '${pageContext.request.contextPath}/getRegisteredClassesDetails.html',
        data: ( {rows: rowInput, page: pageInput, courseId: idInput, regNo: regNoInput}),
        type: 'POST',
        success: function(json_results){
            $('#list').append('<ul></ul>');
            listItems = $('#list').find('ul');
            $.each(json_results.rows, function(courseId) {
            html  = ' Course Name    :  
                    + '<b>' + json_results.rows[courseId].courseName + '</b>';
            html += '</br> Registered Person :  
                    + '<b>' + json_results.rows[courseId].fullName + '</b>';

            listItems.append(html);
            });

            $('#list ul').listview();
         }
    }); 
});

$(function() {
    var currentTime = new Date();
    var month = currentTime.getMonth() + 1;
    var day = currentTime.getDate();
    var year = currentTime.getFullYear();

    if(day<10){
        day='0'+day;
    } 
    if(month<10){
        month='0'+month;
    } 

    var currentTime = new Date();
    var hours = currentTime.getHours();
    var minutes = currentTime.getMinutes();

    var suffix = "AM";
    if (hours >= 12) {
    suffix = "PM";
    hours = hours - 12;
    }
    if (hours == 0) {
    hours = 12;
    }

    if (minutes < 10)
    minutes = "0" + minutes;

    $('#dateTime').html("<b>" + month + "/" + day + "/" + year + "  " + hours + ":" + minutes + " " + suffix + "</b>");
});


    <form id="" action="${pageContext.request.contextPath}/MRegisteredClasses.phone" method="POST">
    <table>
            <tr>
                <td>Date: 
                    <span id="dateTime"></span><br/></td>
            </tr>
            <tr>
                <td>Company:</td>
                <td><input type="text" value=""/><br/></td>
            </tr>
            <tr>
                <td><b>Based on your experience in this course, please answer<br>the following questions:
                <br>1 = Strongly Disagree, 5 = Strongly Agree</b></td>
            </tr>
            <tr>
                <td>The web-based training media used was of high quality.</td>
                <td><select>
                        <option value=""></option>
                        <option value="5">5</option>
                        <option value="5">4</option>
                        <option value="3">3</option>
                        <option value="2">2</option>
                        <option value="1">1</option>
                    </select><br/></td>
            </tr>
            <tr>
                <td>I had enough time to learn the subject matter covered in the course.</td>
                <td><select>
                        <option value=""></option>
                        <option value="5">5</option>
                        <option value="5">4</option>
                        <option value="3">3</option>
                        <option value="2">2</option>
                        <option value="1">1</option>
                    </select><br/></td>
            </tr>
            <tr>
                <td>My knowledge and/or skills increased as a result of this course.</td>
                <td><select>
                        <option value=""></option>
                        <option value="5">5</option>
                        <option value="5">4</option>
                        <option value="3">3</option>
                        <option value="2">2</option>
                        <option value="1">1</option>
                    </select><br/></td>
            </tr>
            <tr>
                <td>Additional comments or ideas to improve this course:</td>
            </tr>
            <tr>
                <td><textarea rows="3" ></textarea></td>
            </tr>
            <tr>
                <td>What additional topics would you like to see addressed in a future online course?</td>
            </tr>
            <tr>
                <td><textarea rows="3"></textarea></td>
            </tr>
            <tr>
                <td align="left">
                    <input type="submit" data-inline="true" id="submit" value="Submit This Survey" class="ui-btn-right"
                        onClick="confirm( 'Thanks for filling the survey' )"/>
                    <a href="${pageContext.request.contextPath}/MRegisteredClasses.phone" class="ui-btn-right"
                        data-role="button" data-inline="true">Cancel</a>
                </td>
            </tr>
    </table>
    </form>

这是我需要导航的页面的代码.

and this is my code for the page that it need to navigate.

<div data-role="page" id="MregisteredClasses">
<div data-role="content">
    <h3>Courses Name</h3>
    <p id="note">*Click at the courses to view the details</p>
    <h1></h1>
    <div id="courseName"> 
        <ul data-role="listview" data-inset="true" id="list"></ul>
        <script type="text/javascript">
            $('#MregisteredClasses').on('pageinit', function(){
                var rowInput = "1";
                var pageInput = "1";

                $.ajax({
                 url: '${pageContext.request.contextPath}/getRegisteredClassesData.html',
                 data: ( {rows : rowInput , page : pageInput}),
                 type: 'POST',

                success: function(json_results){
                    $('#list').append('<ul data-role="listview" data-inset="true" data-split-icon="gear"</ul>');
                    listItems = $('#list').find('ul');
                    $.each(json_results.rows, function(key) {
                      html = '<li <h3><a href="${pageContext.request.contextPath}/MRegisteredClassesDetail.phone?courseId=' 
                             + [json_results.rows[key].courseId] + '&regNo=' + [json_results.rows[key].regNo] +
                             '"rel="external">' + json_results.rows[key].courseName+ '</a></h3>'
                             + '<a href="${pageContext.request.contextPath}/MRateCourse.phone?courseId=' 
                             + [json_results.rows[key].courseId] + '&regNo=' + [json_results.rows[key].regNo] + 
                             '"rel="external">RATE THIS COURSE</a>';
                    listItems.append(html); 
                    });

                $('#list ul').listview(); 
                },
            });
            });
        </script>
    </div> 
</div><!-- /content -->

推荐答案

我已经知道了.我在表单中添加了data-ajax="false".

I got it already.. I add data-ajax="false" to my form.

这篇关于导航页面后数据不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆