Data does not display after navigate page

时间秒杀一切 提交于 2019-12-25 05:27:42

问题


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 -->

回答1:


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



来源:https://stackoverflow.com/questions/10975064/data-does-not-display-after-navigate-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!