Visualizzazione dei risultati da 1 a 10 su 11

Hybrid View

  1. #1
    Utente di HTML.it L'avatar di supermac
    Registrato dal
    Jun 2001
    Messaggi
    1,881
    Grazie vic
    quindi adattando il mio codice a quanto mi suggerisci, secondo te questa in asincrono dovrebbe andare? (sempre se A) ho capito bene, B) l'ho scritta giusta... secondo quel che dice Andrea tu hai usato il POST ma andava usato GET)
    codice:
    function processBarcode(bc) {
            var e = document.getElementById("ddlconti");
            var conto = e.options[e.selectedIndex].value;
            
            var httpRequest = new XMLHttpRequest();
            httpRequest.onreadystatechange = function() {
               if (this.readyState == 4 && this.status == 200) {
                  var risposta =this.responseText;
                  if (risposta == 'True') {
                     //mostro labels
                     document.getElementById("matri").display = "block";
                     document.getElementById("scans").innerHTML += "<div>" + bc + "</div>";
                     document.getElementById("bottoni").style.display = "block";
                  } else {
                     alert('MATRICOLA NON ACCETTATA!');
                  }
               }
            };
    
            httpRequest.open('GET', "maincheck.ashx?c="+conto+"&m="+bc, true);
            httpRequest.send();
        }
    Ultima modifica di supermac; 15-10-2018 a 15:26
    W la Ferari effetrenavenave!
    il computer è un somaro veloce! (neanche tanto ndr)

  2. #2
    Utente di HTML.it L'avatar di vic53
    Registrato dal
    Oct 2010
    residenza
    Fonte Nuova (Roma)
    Messaggi
    592

    differenze tra GET e POST

    Quote Originariamente inviata da supermac Visualizza il messaggio
    Grazie vic
    quindi adattando il mio codice a quanto mi suggerisci, secondo te questa in asincrono dovrebbe andare? (sempre se A) ho capito bene, B) l'ho scritta giusta... secondo quel che dice Andrea tu hai usato il POST ma andava usato GET)
    codice:
    function processBarcode(bc) {
            var e = document.getElementById("ddlconti");
            var conto = e.options[e.selectedIndex].value;
            
            var httpRequest = new XMLHttpRequest();
            httpRequest.onreadystatechange = function() {
               if (this.readyState == 4 && this.status == 200) {
                  var risposta =this.responseText;
                  if (risposta == 'True') {
                     //mostro labels
                     document.getElementById("matri").display = "block";
                     document.getElementById("scans").innerHTML += "<div>" + bc + "</div>";
                     document.getElementById("bottoni").style.display = "block";
                  } else {
                     alert('MATRICOLA NON ACCETTATA!');
                  }
               }
            };
    
            httpRequest.open('GET', "maincheck.ashx?c="+conto+"&m="+bc, true);
            httpRequest.send();
        }
    naturalmente tu come dice Andrea puoi usare GET, nel mio caso uso POSt perchè la molde di dati è diversa e se ti serve inviare molti dati è meglio usare POST di cui il limite è alto come n. di byte che puoi trasmettere... poi con la GET tu devi passare tramite Querystring i dati in chiaro invece in POST
    puoi mandare i dati dinamici del form anche se sono molti comunque vedi tu quale usare al meglio per te
    ciao
    Vic53

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.