Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /** (C) HTML.IT - insieme di funzioni ed oggetti utili per interagire con ajax */
  2.  
  3. /** FUNZIONI */
  4.  
  5.     // funzione per prendere un elemento con id univoco
  6.         function prendiElementoDaId(id_elemento) {
  7.             var elemento;
  8.             if(document.getElementById)
  9.                 elemento = document.getElementById(id_elemento);
  10.             else
  11.                 elemento = document.all[id_elemento];
  12.             return elemento;
  13.         };
  14.    
  15.     // funzione per assegnare un oggetto XMLHttpRequest
  16.         function assegnaXMLHttpRequest() {
  17.             var
  18.                 XHR = null,
  19.                 browserUtente = navigator.userAgent.toUpperCase();
  20.             if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
  21.                 XHR = new XMLHttpRequest();
  22.             else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) {
  23.                 if(browserUtente.indexOf("MSIE 5") < 0)
  24.                     XHR = new ActiveXObject("Msxml2.XMLHTTP");
  25.                 else
  26.                     XHR = new ActiveXObject("Microsoft.XMLHTTP");
  27.             }
  28.             return XHR;
  29.         };
  30.  
  31.  
  32.  
  33. /** OGGETTI / ARRAY */
  34.  
  35.     // oggetto di verifica stato
  36.         var readyState = {
  37.             INATTIVO:   0,
  38.             INIZIALIZZATO:  1,
  39.             RICHIESTA:  2,
  40.             RISPOSTA:   3,
  41.             COMPLETATO: 4
  42.         };
  43.  
  44.     // array descrittivo dei codici restituiti dal server
  45.     // [la scelta dell' array รจ per evitare problemi con vecchi browsers]
  46.         var statusText = new Array();
  47.         statusText[100] = "Continue";
  48.         statusText[101] = "Switching Protocols";
  49.         statusText[200] = "OK";
  50.         statusText[201] = "Created";
  51.         statusText[202] = "Accepted";
  52.         statusText[203] = "Non-Authoritative Information";
  53.         statusText[204] = "No Content";
  54.         statusText[205] = "Reset Content";
  55.         statusText[206] = "Partial Content";
  56.         statusText[300] = "Multiple Choices";
  57.         statusText[301] = "Moved Permanently";
  58.         statusText[302] = "Found";
  59.         statusText[303] = "See Other";
  60.         statusText[304] = "Not Modified";
  61.         statusText[305] = "Use Proxy";
  62.         statusText[306] = "(unused, but reserved)";
  63.         statusText[307] = "Temporary Redirect";
  64.         statusText[400] = "Bad Request";
  65.         statusText[401] = "Unauthorized";
  66.         statusText[402] = "Payment Required";
  67.         statusText[403] = "Forbidden";
  68.         statusText[404] = "Not Found";
  69.         statusText[405] = "Method Not Allowed";
  70.         statusText[406] = "Not Acceptable";
  71.         statusText[407] = "Proxy Authentication Required";
  72.         statusText[408] = "Request Timeout";
  73.         statusText[409] = "Conflict";
  74.         statusText[410] = "Gone";
  75.         statusText[411] = "Length Required";
  76.         statusText[412] = "Precondition Failed";
  77.         statusText[413] = "Request Entity Too Large";
  78.         statusText[414] = "Request-URI Too Long";
  79.         statusText[415] = "Unsupported Media Type";
  80.         statusText[416] = "Requested Range Not Satisfiable";
  81.         statusText[417] = "Expectation Failed";
  82.         statusText[500] = "Internal Server Error";
  83.         statusText[501] = "Not Implemented";
  84.         statusText[502] = "Bad Gateway";
  85.         statusText[503] = "Service Unavailable";
  86.         statusText[504] = "Gateway Timeout";
  87.         statusText[505] = "HTTP Version Not Supported";
  88.         statusText[509] = "Bandwidth Limit Exceeded";