Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ajax] Jak zrobic aby po kliknieciu w link pod spodem pojawila sie tresc danego div-a lub strony html, wiem banal, ale nie moge dojsc :)
jaskooo
post
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 24.04.2004
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Witam wszystkich.
Czarna dziura.

Sprawa wygląda tak:

Chciałbym aby po kliknięciu w link pod spodem wyświetlała sie zawartość odpowiedniego do linka DIV-a lub strony HTML, bez przeładowywania strony.

Wiem, ze to jest podstawa Ajax-a i mógłbym przekopiować gotowy skrypt, ale chciałbym sie nauczyć jak to działa.


Strona wyglada nastepujaco:

galeria.php

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  5. <link rel="stylesheet" type="text/css" href="style.css" />
  6. <title>Galeria</title>
  7.  
  8.  
  9. </head>
  10. <div id="main">
  11.  
  12. <div>
  13. <li><a href="pierwsza.php">Pierwsza</a></li>
  14. <li>href="drugie.php">Druga</a></li>
  15. </div>
  16.  
  17.  
  18.  
  19. </div>
  20.  
  21. </body>
  22. </html>



pierwsza.php
  1.  
  2.  
  3. <?php
  4.  
  5. $dir_arr = scandir('pierwsza/');
  6. array_shift($dir_arr);
  7. array_shift($dir_arr);
  8. array_shift($dir_arr);
  9. foreach($dir_arr as $file)
  10. {
  11.  
  12. echo "<a href=\"\" onclick=\"window.open('zdjecia/$file', '$file','menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no')\"><img style='width: 100px;' src=\"zdjecia/$file\"></img></a>";
  13.  
  14.  
  15. }
  16.  
  17.  
  18.  
  19.  
  20. ?>
  21. </body>
  22. </html>


druga.php
  1. <?php
  2.  
  3. $dir_arr = scandir('druga/');
  4. array_shift($dir_arr);
  5. array_shift($dir_arr);
  6. array_shift($dir_arr);
  7. foreach($dir_arr as $file)
  8. {
  9.  
  10. echo "<a href=\"\" onclick=\"window.open('zdjecia/$file', '$file','menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width=".$szer.", height=".$wys."')\"><img style='width: 100px;' src=\"zdjecia/$file\"></img></a>\n";
  11.  
  12. }
  13.  
  14.  
  15.  
  16.  
  17. ?>




Proszę o pomoc (IMG:http://forum.php.pl/style_emoticons/default/exclamation.gif) !!


Z gory dziekuje (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Kamson
post
Post #2





Grupa: Zarejestrowani
Postów: 57
Pomógł: 3
Dołączył: 23.10.2006
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


gdzie pliki z galeriami to galeria1,galeria2 ....galeria%i ...

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  3. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  4. <link rel="stylesheet" type="text/css" href="style.css" />
  5.  
  6. <script type="text/javascript" src="advajax.js"></script>
  7. <script type="text/javascript" language="javascript">
  8. // <![CDATA[
  9.  
  10. function openGalery(nr) {
  11.  
  12. advAJAX.get({
  13.  
  14. url: "galeria"+nr+".php",
  15. tag: "galery_div",
  16. timeout: 9000,
  17.  
  18. onTimeout : function(){
  19. alert('Uplynal czas zadania, spróbuj ponownie!');
  20. },
  21.  
  22. onLoading : function(obj) {
  23. document.getElementById("galery_div").innerHTML = "Ładuję....";
  24. },
  25.  
  26. onSuccess : function(obj) {
  27. document.getElementById("galery_div").innerHTML = obj.responseText;
  28. },
  29.  
  30. onError : function(obj) {
  31. alert('Wystąpił błąd!')
  32. }
  33.  
  34. });
  35. }
  36.  
  37. // ]]>
  38. </script>
  39. <title>Galeria</title>
  40. </head>
  41. <div id="main">
  42. <ul>
  43. <li><a href="java script:openGalery('1')">Pierwsza</a></li>
  44. <li><a href="java script:openGalery('2')">Druga</a></li>
  45. </ul>
  46. <div id="galery_div"></div>
  47. </div>
  48. </body>
  49. </html>


Ten post edytował Kamson 23.06.2007, 12:22:19
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 10.10.2025 - 08:31