Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [AJAX]Brak wyniku responseText
Forum PHP.pl > Forum > XML, AJAX
daniel1302
  1. /* Nowy obiekt HttpRequest */
  2. function getHttpRequest ()
  3. {
  4.      var request = false;
  5.      try
  6.      {
  7.            /* Próba dla FF > 2/OPERA > 9/IE>7 */
  8.            request = new XMLHttpRequest();
  9.            request.overrideMimeType('text/xml');
  10.      }
  11.      catch (error1)
  12.      {
  13.            try
  14.            {
  15.                  /* Próba dla IE6 */
  16.                  request = new ActiveXObject('Msxml2.XMLHTTP');
  17.            }
  18.            catch (error2)
  19.            {
  20.                  try
  21.                  {
  22.                        /* Próba dla IE 5 */
  23.                        request = new ActiveXObject('Microsoft.XMLHTTP');
  24.                  }
  25.                  catch (error3)
  26.                  {
  27.                        request = false;
  28.                  }
  29.            }
  30.      }
  31.      return request;
  32. }
  33.  
  34. req = getHttpRequest (); //Stwóż obiekt HttpRequest
  35.  
  36. /* Obiekt jądra */
  37. var obj =
  38. {
  39.      url : null,
  40.      onInitialization : null, //Rozpoczynam Ładowanie
  41.      onLoading : null, //Ładuje
  42.      onLoaded : null, //Załadowano
  43.      onError : null, //Błąd
  44.      onSucces : null, //Odebrano
  45.      onComplete : null //Zakończono
  46. }
  47.  
  48. /* Obiekt myAjax*/
  49. var myAjax = new Object();
  50. myAjax.get = function (arguments)
  51. {
  52.      return myAjax.getResult('GET', arguments);
  53. }
  54.  
  55. /* Zwróć wynik */
  56. myAjax.getResult = function(method, arguments)
  57. {
  58.      if (typeof method == 'undefined')
  59.            method = 'GET';
  60.  
  61.      
  62.                        
  63.      
  64. req.open(method, 'data.php');
  65.  
  66. req.send(null);
  67.      
  68.                  alert(req.responseText);
  69.  
  70.            
  71.            
  72.      
  73. }
  74. /* Przypisz arguenty */
  75. myAjax.setArguments = function(arguments)
  76. {
  77.      for (var a in arguments)
  78.      {
  79.            if (arguments[a] != 'req')
  80.                  obj[a] = arguments[a];
  81.      }
  82. }

jest to mój pierwszy większy(powyżej 10 lini) skrypt w JS

Problem polega na tym iż alert(req.responseText) jest pusty.

W Firebugu z GET http://localhost/tcp/data.php 41ms response daje wynik 08:41:18

Co może być iż neimgoe odczytać wyniku
dziękuje
Maxik
Sprawdź czy masz exit; na końcu w pliku PHP winksmiley.jpg
daniel1302
Dziękuje za chęci ale koleś niedał w Arcie:
r.onreadystatechange = function(){}
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.