Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [AJAX]Brak wyniku responseText
daniel1302
post
Post #1





Grupa: Zarejestrowani
Postów: 602
Pomógł: 30
Dołączył: 1.08.2007
Skąd: Nowy Sącz

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


  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
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
Maxik
post
Post #2





Grupa: Zarejestrowani
Postów: 726
Pomógł: 129
Dołączył: 10.01.2008
Skąd: Gdańsk

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


Sprawdź czy masz exit; na końcu w pliku PHP winksmiley.jpg


--------------------
Pomogłem? Kliknij przycisk Pomógł pod pomocnym Ci postem.
http://maxik.me/
Go to the top of the page
+Quote Post
daniel1302
post
Post #3





Grupa: Zarejestrowani
Postów: 602
Pomógł: 30
Dołączył: 1.08.2007
Skąd: Nowy Sącz

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


Dziękuje za chęci ale koleś niedał w Arcie:
r.onreadystatechange = function(){}
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 21.08.2025 - 07:09