未捕获的TypeError:undefined不是一个函数(匿名函数)php javascript

时间:2014-12-15 13:18:22

标签: javascript php jquery pagination

我对javascript不太熟悉,我在这里也很新。我在控制台上收到一条错误,指出Uncaught TypeError:undefined不是函数。

我正在尝试对表进行排序并在php中创建分页。没有致命的错误,但它不起作用。我不知道为什么。这是我的代码:

的header.php

<!-- Mobile viewport optimisation -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- Add meta data here -->

<link id="bootstrapFlexible" href="styles/flexible-columns.css" rel="stylesheet" type="text/css"/>

<link id="bootstraptheme" rel="stylesheet" type="text/css" href="css/bootstrap.css">



<link rel="stylesheet" type="text/css" href="css/jquery.css" />

<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/jquery.tablesorter.js" type="text/javascript"></script> 
<script type="text/javascript"> 
    $(document).ready(function() { 
        $("table").tablesorter({ 
            sortList: [[2,0]],
            // pass the headers argument and assing a object 
            headers: { 
                // assign the secound column (we start counting zero) 
                5: { 
                    // disable it by setting the property sorter to false 
                    sorter: false 
                }           
            } 
        }); 
    });
</script>

<meta charset="utf-8"/>

    <script>
        function settheme() {
            if (localStorage.getItem("settheme") === null) {

            }else{
                var theme = localStorage['settheme'];
                document.getElementById('bootstraptheme').href = theme;
            }
        };
         window.onload = settheme;

    </script>

这是我的表:

$query = $dbh -> query("SELECT COUNT(*) FROM reminders r 
        JOIN reminder_type rt 
        ON r.type_of_reminder = rt.reminder_type_id
        JOIN subjects s
        ON r.subject = s.subject_id");

$num_rows=$query->rowCount();
$rows = $query->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT);
$pages = new Paginator;
$pages->items_total = $rows[0];
$pages->mid_range = 5; // Number of pages to display. Must be odd and > 3
$pages->paginate();
echo $pages->display_pages();
echo "<span class=\"\">".$pages->display_jump_menu().$pages->display_items_per_page()."</span>";

echo "<form method='POST'>
    <input type='text' name='search_key'/>
    <input type='submit' name='search_button' value='S E A R C H'/>
    </form>";

echo '<table style="width:100%;margin:auto; text-align: center;" id="bord" class="tablesorter">';
echo '<thead id="table_head">
<tr style="height:50px;font-size:18px;font-weight:bold; background:#00a651; color:#fff;"">';
echo "  <th class='thh'>Name</th>
        <th class='thh'>Subject</th>
        <th class='thh'>Reminder Type</th>
        <th class='thh'>Description</th>
        <th class='thh'>Date of Deadline</th>
        <th class='thh'>Time of Deadline</th>
        <th>Option</th>
        </tr></thead>
        <tbody>";

这是我从网上获得的paginator课程。

我感谢你们所有的建议。我已经抬头看了SO但我似乎无法找到解决方案。所以,谢谢你们,伙计们!

1 个答案:

答案 0 :(得分:0)

在你放的脚本部分};关闭函数settheme()。

<script>
    function settheme() {
        if (localStorage.getItem("settheme") === null) {

        }else{
            var theme = localStorage['settheme'];
            document.getElementById('bootstraptheme').href = theme;
        }
    };

尝试删除额外的内容;