Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [advAJAX] 2 Problemy
Forum PHP.pl > Forum > XML, AJAX > AJAX
Smeagol
Witam,

2 pytania:

Dlaczego nie działa pod IE
Dlaczego po klikniecie na link obniża wyświetlane dane o jeden enter

oto kod:
Kod:
  1. function $(id) {
  2.  
  3. return document.getElementById(id);
  4. }
  5.  
  6. function parseRecords(xml) {
  7.  
  8. record = xml.getElementsByTagName("record");
  9. result = "";
  10.  
  11. with (xml.getElementsByTagName("records").item(0)) {
  12.  
  13. $("d").innerHTML = "";
  14. }
  15.  
  16. for ( j=0; j<record.length; j++ )
  17. {
  18. tr = document.createElement("tr");
  19.  
  20. for ( i=0; i<record[j].childNodes.length; i++ )
  21. {
  22. if(record[j].childNodes[i].hasChildNodes()) {
  23. td = document.createElement("td");
  24. td.innerHTML = record[j].childNodes[i].childNodes[0].nodeValue;
  25. tr.appendChild(td);
  26. }
  27. }
  28. d.appendChild(tr);
  29. }
  30. return result;
  31. }
  32.  
  33. function getRecords(t) {
  34.  
  35.  
  36. advAJAX.get({
  37.  
  38. url : "test.php",
  39. parameters:{
  40. t: t,
  41.  
  42. },
  43. onInitialization : function() {
  44.  
  45. $("d").innerHTML = 'Pobieranie danych...';
  46.  
  47. },
  48. onSuccess : function(obj) {
  49.  
  50. parseRecords(obj.responseXML);
  51. }
  52. });
  53. }

Kod:
  1.  
  2. <meta http-equiv="Content-Language" content="pl">
  3. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
  4. <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
  5. <meta name="ProgId" content="FrontPage.Editor.Document">
  6. <title>New Page 1</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8. <script type="text/javascript" src="advajax.js"></script>
  9. <script type="text/javascript" src="2.js"></script>
  10. </head>
  11. </head>
  12.  
  13.  
  14. <table border="0" cellpadding="0" cellspacing="0" width="100%" height="1">
  15. <tr>
  16. <td width="36%" valign="top" height="1">
  17. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  18. <tr>
  19. <td width="100%">
  20. <a href="java script:getRecords('165')">mecz2</a><br>
  21. <a href="java script:getRecords('163')">mecz3</a>
  22. </td>
  23. </tr>
  24. </table>
  25. </td>
  26. <td width="36%" valign="top" height="1">
  27. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  28. <tr>
  29. <td width="100%">
  30. <table cellpadding="1" cellspacing="1">
  31.  
  32. <tbody id="d">
  33.  
  34. </td>
  35. </tr>
  36. </table>
  37. </td>
  38. </tr>


Kod:
  1. <?
  2. header("Content-type: text/xml; charset=UTF-8"); 
  3.  
  4.  
  5.  
  6. include "config.inc.php";
  7.  
  8.  
  9. $conn = mysql_connect($server, $identyfikator, $haslo)
  10. or die ("Nie udało się połączyć z bazą danych!");
  11. or die ("Nie udało się wybrać bazy!");
  12.  
  13.  
  14. $query="SELECT * FROM towar2 WHERE id_towaru2='$t'";
  15. $result = mysql_query($query);
  16.  
  17. $i=1;
  18.  
  19.  
  20. echo '<?xml version="1.0" encoding="UTF-8"?><records>';
  21.  while ($row = mysql_fetch_assoc($result)){
  22. echo '<record>';
  23. echo '<name>';
  24.  echo $row["id_towaru2"];
  25. echo '</name>';
  26. echo '<surname>';
  27.  echo $row["zdarzenie2"];
  28. echo '</surname>';
  29. echo '<telephone>';
  30.  echo $row["datarozpoczecia2"];
  31. echo '</telephone>';
  32. echo '<telephone2>';
  33.  echo $row["kurs12"];
  34. echo '</telephone2>';
  35. echo '</record>';
  36. }
  37.  echo '</records>';
  38.  
  39. ?>




i link do dzialajacego skryptu pod firexoks

http://sport.nazwa.pl/ajax/
TomASS
ad 1.:
skąd ten biedy IE ma wiedzieć co to jest 'd'?
Kod
   d.appendChild(tr);

(linia 39 w pliku 2.js). Z resztą FF też zgłasza ten sam błąd smile.gif Tylko jest bardziej domyślny tongue.gif

ad 2:
zobacz w źródło tej strony i powiedz mi dlaczego przed nazwiskiem są jakieś znaki?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.