2014-12-15 2 views
0

Я не очень хорошо знаком с javascript, и я тоже здесь довольно новый. Я получаю сообщение об ошибке на консоли, в которой говорится, что Uncaught TypeError: undefined не является функцией.Uncaught TypeError: undefined не является функцией (анонимная функция) php javascript

Я пытаюсь сортировать таблицу и создавать разбиение на страницы в 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, но я не могу найти решение. Итак, спасибо, ребята!

+0

Мы не используем PHP-код, публикуем сгенерированный HTML-код, чтобы мы могли что-то увидеть! Еще лучше будет JSfiddle! –

+0

Это поможет? @MichaelLumbroso [link] (https://www.dropbox.com/s/91jng1ra6xh9lun/viewReminder.php?dl=0) –

ответ

0

На стороне скрипта вы положили}; для закрытия функции settheme().

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

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

Попробуйте удалить дополнительные;

+0

Спасибо за ответ. Но это все еще не сработало. –

+0

По-прежнему такая же ошибка? Нет строки для ошибки? –

+0

По-прежнему такая же ошибка, вот строка, о которой говорит консоль, имеет ошибку. . '$ (" table "). Tablesorter ({' –

Смежные вопросы