0

使用 jQuery-Mobile-Listview-Pagination-Plugin 时出错

我使用了 jQuery-Mobile-Listview-Pagination-Plugin 我在 JS 中有一个错误说

ReferenceError: _getAjaxCall 未定义 [Break On This Error]
var ajaxCallback = _getAjaxCall();

我的 index.html 代码是:

 <html>

 <head>

 <title>Makanak</title>

 <meta charset="utf-8"/>

 <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-      scale=1.0 width=device-width, user-scalable=no'/> 

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-  1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
    <script type="text/javascript" src="jquery.mobile.listomatic.js"></script>
<script>
$(document).on("pageinit", function(){
var serviceURL = "returns-json-numbers.php"; 
var getNumber = function() {
    return $.ajax({
        type: "post",
        beforeSend: function() { $.mobile.loading( 'show' ) }, //Show spinner
        complete: function() { $.mobile.loading( 'hide' ) }, //Hide spinner
        async: "true",
        dataType: 'json',
        url: serviceURL,
        data: { listomatic: $.mobile.listomatic.prototype.getResults() },
        success: function(data) {
            if (data && data.numbers) {
                var list = '';
                $.each(data.numbers, function(index, value) {
                    list += '<li data-icon="false" data-filtertext="' + value.date + '">' +
                            '<div class="latestNumber">' +
                            '<span class="circle">' + value.number[1] + '</span>' +
                            '</div>' +
                            '<p style="text-align:center;" class="latestNumberDate">' + value.date + '</p>' +
                            '</li>';
                }); // end each 
                $('#listview').append(list).listview("refresh");
            } // end if
        } // end success
    }); // end ajax
}
$.extend($.mobile.listomatic.prototype.options, {perPage: 2, btnLabel: 'Show Me More', refreshContent: 'daily'});
$.mobile.listomatic.prototype.registerAjaxCall(getNumber);
$.extend($.mobile.listomatic.prototype.options, {perPage: 2, 
                                                btnLabel: 'Show Me More', 
                                                refreshContent: 'daily',
                                                noResultsFound: 'No Results Found'
                                                });
});    
</script>
    </head>
<body>

    <!---------------------------- Start home page ---------------------------------------------->       
    <div data-role="page" id="home" >
        <div data-role="header" data-theme="b">
             </div>
        <div data-role="content">   
<ul id="listview" data-role="listview" data-filter="true" data-listomatic="true"></ul>
  </div><!-- /content -->

    </div>

        </body>

我的回报-json-numbers.php 代码:

 <?php 
error_reporting(0);
header('Access-Control-Allow-Origin: *');
$con=mysqli_connect("localhost","root","","intsys");
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$perPage    = $_REQUEST['listomatic']['perPage'];
$listOffset = $_REQUEST['listomatic']['listOffset'];
$searchTerm = $_REQUEST['listomatic']['searchTerm'];

if ($searchTerm) {
    $sql = "SELECT SQL_CALC_FOUND_ROWS *
            FROM waiting_student_branch_course_details 
            WHERE date LIKE '%$searchTerm%'
            ORDER BY id ASC
            LIMIT $listOffset, $perPage";
} else {
    $sql = "SELECT SQL_CALC_FOUND_ROWS *
            FROM waiting_student_branch_course_details 
            ORDER BY id ASC
            LIMIT $listOffset, $perPage";
}
$result = mysqli_query($con, $sql);

// If you are using MySQL use SQL_CALC_FOUND_ROWS in your main queries (above)
// Now to get the total records available use the FOUND_ROWS() function (below)
$resultNumRows = mysqli_query($con, 'SELECT FOUND_ROWS() as foundRows');
$rowFoundRows = mysqli_fetch_array($resultNumRows);
$iFoundRows = $rowFoundRows['foundRows'];

while($row = mysqli_fetch_array($result)) {
     $sDate = date('m/d/Y', strtotime($row['at_time']));
     // Listomatic requires the "total" field to show/hide the "Show More" button
    $aData['total'] = $iFoundRows; 
    // The following is sample data (in this case Powerball numbers) that you want to     display
    $aData['numbers'][] = array('date' =>  $sDate,
                                'number' => array(1 => $row['id']
                                                    ));
}
echo json_encode($aData);
exit;
?>

我从https://github.com/stakbit/jQuery-Mobile-Listview-Pagination-Plugin下载插件

4

0 回答 0