Visualizzazione dei risultati da 1 a 10 su 10

Hybrid View

  1. #1
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669
    codice:
    var xmlhttpPost = (function () {
    
        function reqListener () {
            alert(this.responseText);
            oWait.parentNode && oWait.parentNode.removeChild(oWait);
        }
    
        function reqError (oEvent) {
            alert("C\'\u00E8 stato un errore durante la chiamata AJAX.");
            oWait.parentNode && oWait.parentNode.removeChild(oWait);
        }
    
        var oWait = document.createElement("div");
    
        /* "oWait" e' un div... ci puoi mettere dentro tutto quello che ti pare... */
        oWait.appendChild(document.createTextNode("Attendi..."));
    
        return function (sURL) {
            var oReq = new XMLHttpRequest();
            oReq.onload = reqListener;
            oReq.onerror = reqError;
            oReq.open("GET", sURL, true);
            oReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            oReq.send(recuperaValore());
            oWait.parentNode || document.body.appendChild(oWait);
    
        };
    
    })();
    Tutto ciò che fai con jQuery puoi farlo meglio e con la metà del codice in puro JavaScript.

  2. #2
    Quote Originariamente inviata da carlomarx Visualizza il messaggio
    codice:
    var xmlhttpPost = (function () {
    
        function reqListener () {
            alert(this.responseText);
            oWait.parentNode && oWait.parentNode.removeChild(oWait);
        }
    
        function reqError (oEvent) {
            alert("C\'\u00E8 stato un errore durante la chiamata AJAX.");
            oWait.parentNode && oWait.parentNode.removeChild(oWait);
        }
    
        var oWait = document.createElement("div");
    
        /* "oWait" e' un div... ci puoi mettere dentro tutto quello che ti pare... */
        oWait.appendChild(document.createTextNode("Attendi..."));
    
        return function (sURL) {
            var oReq = new XMLHttpRequest();
            oReq.onload = reqListener;
            oReq.onerror = reqError;
            oReq.open("GET", sURL, true);
            oReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            oReq.send(recuperaValore());
            oWait.parentNode || document.body.appendChild(oWait);
    
        };
    
    })();
    non mi è chiaro, devo eliminare il mio codice e sostituirlo con quello oppure devo aggiungerlo al mio?
    ho provato in tutti e due i modi ma niente non va, o meglio funziona ma la scritta attendi alla fine non va via


    via //Se lo stato è completo
    if (self.xmlHttpReq.readyState == 4) {

    document.getElementById( 'loader' ).removeChild( tuaGif );

    /* Aggiorno la pagina con la risposta ritornata dalla precendete richiesta dal web server.Quando la richiesta è terminata il responso della richiesta è disponibie come responseText.*/
    aggiornaPagina(self.xmlHttpReq.responseText);
    }
    non so perchè ma non funziona neanche quast'altra soluzione potreste farmi un esempio concreto?
    grazie mille =)

  3. #3
    up

  4. #4
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669
    Quote Originariamente inviata da againhere Visualizza il messaggio
    non mi è chiaro, devo eliminare il mio codice e sostituirlo con quello oppure devo aggiungerlo al mio?
    ho provato in tutti e due i modi ma niente non va, o meglio funziona ma la scritta attendi alla fine non va via
    creati un file chiamato "testo.txt", inseriscilo nella stessa cartella della pagina che ti allego. Scrivici dentro "Ciao mondo".

    pagina.html
    :
    codice:
    <!doctype html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Esempio</title>
    <script type="text/javascript">
    function recuperaValore () {
        /* non conosco lo scopo di questa funzione... di conseguenza... */
        return "tizio=caio&ciao=mondo";
    }
    
    var xmlhttpPost = (function () {
    
        function reqListener () {
            alert(this.responseText);
            oWait.parentNode && oWait.parentNode.removeChild(oWait);
        }
    
        function reqError (oEvent) {
            alert("C\'\u00E8 stato un errore durante la chiamata AJAX.");
            oWait.parentNode && oWait.parentNode.removeChild(oWait);
        }
    
        var oWait = document.createElement("div");
    
        /* "oWait" e' un div... ci puoi mettere dentro tutto quello che ti pare... */
        oWait.appendChild(document.createTextNode("Attendi..."));
    
        return function (sURL) {
            var oReq = new XMLHttpRequest();
            oReq.onload = reqListener;
            oReq.onerror = reqError;
            oReq.open("GET", sURL, true);
            oReq.send(recuperaValore());
            oWait.parentNode || document.body.appendChild(oWait);
    
        };
    
    })();
    </script>
    </head>
    
    <body>
    <p><span style="color: #0000ff; text-decoration: underline; cursor: pointer;" onclick="xmlhttpPost('testo.txt');">Clicca qui</span></p>
    </body>
    </html>
    Tutto ciò che fai con jQuery puoi farlo meglio e con la metà del codice in puro JavaScript.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.