Witam,

mam oto sobie taki kodzik:

  1. // przechowuje obiekt XMLHttpRequest
  2. var xmlHttp = createXmlHttpRequestObject();
  3. // inicjalizuje pamięć podręczną żądania
  4. var cache = new Array();
  5. // tworzy obiekt XMLHttpRequest
  6. function createXmlHttpRequestObject()
  7. {
  8. // przechowa odwołanie do obiektu XMLHttpRequest
  9. var xmlHttp;
  10. // powinno działać dla wszystkich przeglądarek z wyjątkiem IE6 i starszych
  11. try
  12. {
  13. // próbuje stworzyć obiekt XMLHttpRequest
  14. xmlHttp = new XMLHttpRequest();
  15. }
  16. catch(e)
  17. {
  18. // zakładając, że IE6 lub starsza
  19. var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
  20. "MSXML2.XMLHTTP.5.0",
  21. "MSXML2.XMLHTTP.4.0",
  22. "MSXML2.XMLHTTP.3.0",
  23. "MSXML2.XMLHTTP",
  24. "Microsoft.XMLHTTP");
  25. // sprawdza każdy prog id aż któryś zadziała
  26. for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
  27. {
  28. try
  29. {
  30. // próbuje stworzy&#263; obiekt XMLHttpRequest
  31. xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
  32. }
  33. catch (e) {} // ignoruje potencjalne b&#322;&#281;dy
  34. }
  35. }
  36. // zwraca stworzony obiekt albo wy&#347;wietla komunikat o b&#322;&#281;dzie
  37. if (!xmlHttp)
  38. displayError("Błąd podczas tworzenia obiektu XMLHttpRequest.");
  39. else
  40. return xmlHttp;
  41. }
  42.  
  43.  
  44.  
  45.  
  46.  
  47. function validate(inputValue, fieldID)
  48. {
  49.  
  50. if(xmlHttp)
  51. {
  52. if(fieldID)
  53. {
  54. inputValue = encodeURIComponent(inputValue);
  55. fieldID = encodeURIComponent(fieldID);
  56. cache.push("inputValue=" + inputValue + "&fieldID=" + fieldID);
  57. }
  58.  
  59. try
  60. {
  61. if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0 && cache.length > 0)
  62. {
  63. var cacheEntry = cache.shift();
  64.  
  65. xmlHttp.open("POST", "validate.php", true);
  66. xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  67. xmlHttp.onreadystatechange = HandleReServer;
  68. xmlHttp.send(cacheEntry);
  69. }
  70.  
  71. }
  72. catch(e)
  73. {
  74. alert("Wystąpił błąd !2");
  75. }
  76. }
  77. }
  78.  
  79. function HandleReServer()
  80. {
  81. if(xmlHttp.readyState == 4)
  82. {
  83. if(xmlHttp.status == 200)
  84. {
  85. try
  86. {
  87. ReadHandle();
  88. }
  89. catch(e)
  90. {
  91. alert("Wystąpił błąd !5");
  92. }
  93.  
  94. }
  95.  
  96.  
  97. else
  98. {
  99. alert("Wystąpił błąd !3");
  100. }
  101.  
  102. }
  103. }
  104.  
  105. function ReadHandle()
  106. {
  107.  
  108. responseXml = xmlHttp.responseXML;
  109.  
  110. xmlDoc = responseXml.documentElement;
  111. result = xmlDoc.getElementsByTagName("result")[0].firstChild.data;
  112. fieldid = xmlDoc.getElementsByTagName("fieldid")[0].firstChild.data;
  113.  
  114. message = document.getElementById(fieldid + "Failed");
  115. message.className = (result == 0) ? "error" : "hidden";
  116.  
  117. }


Gdy dodaje do funkcji ReadHandle, czy też validate - setTimeout(); wyświetla mi komunikat w alert();

  1. catch(e)
  2. {
  3. alert("Wystąpił błąd !5");
  4. }


Jak temu zapobiec, proszę o cenne informacje i uwagi ? Pozdrawiam