Witam. Posiadam własną klasę która obsługuje wyświetlanie stron Urle wyświetlane są następująco

strona główna to nazwa-domeny.pl/start
po wpisaniu nazwa-strony.pl/start/ (łamaniec na końcu)
także wczytuje mi się strona główna



postanowiłem dodać skrypt który pobiera dane na żywo asynchronicznie (KOD PONIŻEJ)
kiedy wpisze końcówkę w url z łamańcem lub co kolwiek po np nazwa-strony.pl/start/xxxxx

w DIVIE który wyświetla zawartość danych wczytuję mi się w kółko strona a w stronie jeszcze raz strona itd aż firefox się zawiesza

pod adresem nazwa-strony.pl/start wszystko chodzi wyśmienicie
czy mógł by ktoś naprowadzić mnie jak rozwiązać ten problem z url który rozsypuje mi stronę tym skryptem

dane wyświetlają się w DIVIE container i po wpisaniu nazwa-strony.pl/start/xxx próbuję się władować tam cała strona raz jeszcze.

pagination.php
  1. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  2. <script type="text/javascript">
  3. $(document).ready(function(){
  4. function loading_show(){
  5. $('#loading').html("/images/loading.gif'/>").fadeIn('fast');
  6. }
  7. function loading_hide(){
  8. $('#loading').fadeOut('fast');
  9. }
  10. function loadData(page){
  11. loading_show();
  12. $.ajax
  13. ({
  14. type: "POST",
  15. url: "view/paginationNEWS/load_data.php",
  16. data: "page="+page,
  17. success: function(msg)
  18. {
  19. $("#container").ajaxComplete(function(event, request, settings)
  20. {
  21. loading_hide();
  22. $("#container").html(msg);
  23. });
  24. }
  25. });
  26. }
  27. loadData(1); // For first time page load default results
  28. $('#container .pagination li.active').live('click',function(){
  29. var page = $(this).attr('p');
  30. loadData(page);
  31.  
  32. });
  33. $('#go_btn').live('click',function(){
  34. var page = parseInt($('.goto').val());
  35. var no_of_pages = parseInt($('.total').attr('a'));
  36. if(page != 0 && page <= no_of_pages){
  37. loadData(page);
  38. }else{
  39. alert('Enter a PAGE between 1 and '+no_of_pages);
  40. $('.goto').val("").focus();
  41. return false;
  42. }
  43.  
  44. });
  45. });
  46. </script>
  47.  
  48. <style type="text/css">
  49. #loading{
  50. display:inline;
  51. z-index:2;
  52.  
  53. width: 200px;
  54. position: absolute;
  55. top: 222px;
  56.  
  57. margin-left:222px;
  58. margin-top:200px;
  59.  
  60. }
  61. #container .pagination ul li.inactive,
  62. #container .pagination ul li.inactive:hover{
  63. background-color:#ededed;
  64. color:#bababa;
  65. border:1px solid #bababa;
  66. cursor: default;
  67. }
  68.  
  69.  
  70. #container .pagination{
  71. width: auto;
  72. height: 25px;
  73. }
  74. #container .pagination ul li{
  75. list-style: none;
  76. float: left;
  77. border: 1px solid #006699;
  78. padding: 2px 5px 2px 5px;
  79. margin: 0 2px 0 2px;
  80. font-family: arial;
  81. font-size: 14px;
  82. color: #006699;
  83. font-weight: bold;
  84. background-color: #f2f2f2;
  85. }
  86. #container .pagination ul li:hover{
  87. color: #fff;
  88. background-color: #006699;
  89. cursor: pointer;
  90. }
  91. .go_button
  92. {
  93. background-color:#f2f2f2;border:1px solid #006699;color:#cc0000;padding:2px 6px 2px 6px;cursor:pointer;position:absolute;margin-top:-1px;
  94. }
  95. .total
  96. {
  97. float:right;font-family:arial;color:#999; margin-right:9px;
  98. }
  99.  
  100. </style>
  101.  
  102. </head>
  103. <body>
  104. <div id="loading"></div>
  105.  
  106. <div align="center" style="font-size:24px;color:#cc0000;font-weight:bold"></div>
  107.  
  108. <div id="container">
  109. <div class="data"></div>
  110. <div class="pagination"></div>
  111. </div> <div class="clr"></div>
  112.  


load_data.php

  1. <?php
  2. if($_POST['page'])
  3. {
  4. $page = $_POST['page'];
  5. $cur_page = $page;
  6. $page -= 1;
  7. $per_page = 2;
  8. $previous_btn = true;
  9. $next_btn = true;
  10. $first_btn = true;
  11. $last_btn = true;
  12. $start = $page * $per_page;
  13. include"./../../classes/baseOld.php";
  14.  
  15. $query_pag_data = "SELECT msg_id,message from messages LIMIT $start, $per_page";
  16. $result_pag_data = mysql_query($query_pag_data) or die('MySql Error' . mysql_error());
  17. $msg = "";
  18. while ($row = mysql_fetch_array($result_pag_data)) {
  19. $source=$row['message'];
  20. $htmlmsg=htmlspecialchars($source, ENT_QUOTES, 'UTF-8');
  21.  
  22.  
  23. //$htmlmsg=htmlentities($row['message']);
  24. //$new = htmlspecialchars("$htmlmsg", ENT_QUOTES);
  25. //$htmlmsg=($row['message']);
  26. $msg .= "<li><b>" . $row['msg_id'] . "</b> " . $htmlmsg . "</li><BR><BR><BR>
  27. ";
  28. }
  29. $msg = "<div class='data'><ul>" . $msg . "</ul></div>"; // Content for Data
  30.  
  31.  
  32. /* --------------------------------------------- */
  33. $query_pag_num = "SELECT COUNT(*) AS count FROM messages";
  34. $result_pag_num = mysql_query($query_pag_num);
  35. $row = mysql_fetch_array($result_pag_num);
  36. $count = $row['count'];
  37. $no_of_paginations = ceil($count / $per_page);
  38.  
  39. /* ---------------Calculating the starting and endign values for the loop----------------------------------- */
  40. if ($cur_page >= 7) {
  41. $start_loop = $cur_page - 3;
  42. if ($no_of_paginations > $cur_page + 3)
  43. $end_loop = $cur_page + 3;
  44. else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6) {
  45. $start_loop = $no_of_paginations - 6;
  46. $end_loop = $no_of_paginations;
  47. } else {
  48. $end_loop = $no_of_paginations;
  49. }
  50. } else {
  51. $start_loop = 1;
  52. if ($no_of_paginations > 7)
  53. $end_loop = 7;
  54. else
  55. $end_loop = $no_of_paginations;
  56. }
  57. /* ----------------------------------------------------------------------------------------------------------- */
  58. $msg .= "<div class='pagination'><ul>";
  59.  
  60. // FOR ENABLING THE FIRST BUTTON
  61. if ($first_btn && $cur_page > 1) {
  62. $msg .= "<li p='1' class='active'> &lt&lt;Pocz.</li>";
  63. } else if ($first_btn) {
  64. $msg .= "<li p='1' class='inactive'>&lt&lt;Pocz.</li>";
  65. }
  66.  
  67. // FOR ENABLING THE PREVIOUS BUTTON
  68. if ($previous_btn && $cur_page > 1) {
  69. $pre = $cur_page - 1;
  70. $msg .= "<li p='$pre' class='active'>&ltPoprz.</li>";
  71. } else if ($previous_btn) {
  72. $msg .= "<li class='inactive'>&ltPoprz.</li>";
  73. }
  74. for ($i = $start_loop; $i <= $end_loop; $i++) {
  75.  
  76. if ($cur_page == $i)
  77. $msg .= "<li p='$i' style='color:#fff;background-color:#006699;' class='active'>{$i}</li>";
  78. else
  79. $msg .= "<li p='$i' class='active'>{$i}</li>";
  80. }
  81.  
  82. // TO ENABLE THE NEXT BUTTON
  83. if ($next_btn && $cur_page < $no_of_paginations) {
  84. $nex = $cur_page + 1;
  85. $msg .= "<li p='$nex' class='active'>Nast.></li>";
  86. } else if ($next_btn) {
  87. $msg .= "<li class='inactive'>Nast.></li>";
  88. }
  89.  
  90. // TO ENABLE THE END BUTTON
  91. if ($last_btn && $cur_page < $no_of_paginations) {
  92. $msg .= "<li p='$no_of_paginations' class='active'>Ost.>></li>";
  93. } else if ($last_btn) {
  94. $msg .= "<li p='$no_of_paginations' class='inactive'>Ost.>></li>";
  95. }
  96. //$goto = "<input type='text' class='goto' size='1' style='margin-top:-1px;margin-left:60px;'/><input type='button' id='go_btn' class='go_button' value='Go'/>";
  97. $total_string = "<span class='total' a='$no_of_paginations'>Strona <b>" . $cur_page . "</b> z <b>$no_of_paginations</b></span>";
  98. $msg = $msg . "</ul>" . $goto . $total_string . "</div>"; // Content for pagination
  99. echo $msg;
  100. } ?><div class="clr"></div>
  101.  
  102.