Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870

    Please wait con Ajax e open Post

    Ciao a tutti.

    Ho un problema che non riesco a risolvere ma soprattutto a capire la causa.

    All'invio del form postato di seguito dovrebbe visualizzarsi la classica immagine `Please wait`, invece quando invio il form prima si attiva la alert 'The server script has now completed' e quando clicco su `ok` si apre la pagina che processa i dati lato server.

    Nell'onsubmit del form ho previsto la funzione di controllo `atLeastOneChecked` che quando è soddisfatta dovrebbe richiamare la funzione `longcall();`.

    Questo accade ma non come mi aspettavo... potete darmi un suggerimento?

    Grazie mille!


    codice:
    <html>
     
    <head>
    <meta http-equiv="Content-Language" content="it">
    <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Test</title>
    
    <script language="javascript" type="text/javascript"> 
    // <!CDATA[
     
            function loadXMLDoc()
            {
            try {
            req = new XMLHttpRequest();
              } catch (err1)
              {
              try {
              req = new ActiveXObject("Msxml12.XMLHTTP");
              } catch (err2)
              {
              try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (err3)
                {
    	req = false;
                }
              }
    	}
            return req;
    	}
     
            
            var http = loadXMLDoc()        
            
            function handleHttpResponse() {
            if (http.readyState == 4 && http.status==200) {
                  document.getElementById('wait').style.visibility = "hidden";
                  alert('The server script has now completed');
               } else {
                  document.getElementById('wait').style.visibility = "visible";
                }
            }
     
            function longcall() {
            myRand=parseInt(Math.random()*999999);
            http.open("POST","_inc_upd.asp",true);
            http.onreadystatechange = handleHttpResponse;
            http.send();
            }
            
            
     
    function PopUp() {
     
       var w = 500;
       var h = 300;
       var l = Math.floor((screen.width-w)/2);
       var t = Math.floor((screen.height-h)/2);
     
       finestra=window.open('_inc_pagina_commento.asp','','width=' + w + ',height='+ h + ',top=' + t + ',left=' + l+',scrollbars=no,menubar=no,toolbar=no,status=no');
     
    }
     
    function atLeastOneChecked(form) {
     
       var inputs = form.getElementsByTagName('input');
       var i = inputs.length;
       while (i--) {   
          
          if(inputs[i].checked && !inputs[i].disabled)
          
             if(confirm("Confermi?.")) {
                PopUp();             
                return false;
                } else {            
                longcall();                        
                return true; 
                }          
       }
       
       alert("Stop!")
       return false;     
     
    }
     
    // ]]>
    </script>
     
    ...  
          
    <form name=frmTest action="_inc_upd.asp" method=POST onsubmit="return atLeastOneChecked(this)">
    
    
    
    
    <input type=checkbox name=chkParent25 value=21118>
    </p>
    
    
    
    
    <input type=checkbox name=chkParent26 value=21119>
    </p>
    
    
    
    
    <input type="image" src="/images/assegnazione_button.gif" border="0"></p>
    </form>    
          
    <div id="wait" style="background-color:white;position:absolute;top:240px;left:360px;width:70px;height:50px;visibility:hidden;border: 1px solid black;padding:20px;">
          [img]/images/ajax-loader.gif[/img]
    
    
    Please wait...
    </div>
    
    ...

  2. #2
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870
    Ho corretto una svista, ma non c'è niente da fare... continua prima ad aprire la alert 'The server script has now completed' e quando clicco su `ok` si apre la pagina che processa i dati lato server.




    codice:
    <html>
    
    <head>
    <meta http-equiv="Content-Language" content="it">
    <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Test</title>
    
    <head>
    
    <script language="javascript" type="text/javascript">
    // <!CDATA[
    
            function loadXMLDoc()
    
            {
    
            try {
    
            req = new XMLHttpRequest();
    
              } catch (err1)
    
              {
    
              try {
    
              req = new ActiveXObject("Msxml12.XMLHTTP");
    
              } catch (err2)
    
              {
    
              try {
    
                req = new ActiveXObject("Microsoft.XMLHTTP");
    
                } catch (err3)
    
                {
    
                req = false;
    
                }
    
              }
    
                }
    
            return req;
    
                }
    
     
    
           
    
            var http = loadXMLDoc()       
    
           
    
            function handleHttpResponse() {
    
            if (http.readyState == 4 && http.status==200) {
    
                  document.getElementById('wait').style.visibility = "hidden";
                  alert('The server script has now completed');
    
               } else {
    
                  document.getElementById('wait').style.visibility = "visible"; 
    
                }
    
            }
    
           
    
            function longcall() {
            
            var url = 'default-2.asp?rand=';
    
            myRand=parseInt(Math.random()*9999999999);
    
            http.open("POST", url + myRand, true);
    
            http.onreadystatechange = handleHttpResponse;
    
            http.send();
    
            }
    
           
    
           
    
     
    
    function PopUp() {
    
     
    
       var w = 500;
    
       var h = 300;
    
       var l = Math.floor((screen.width-w)/2);
    
       var t = Math.floor((screen.height-h)/2);
    
     
    
       finestra=window.open('_inc_pagina_commento.asp','','width=' + w + ',height='+ h + ',top=' + t + ',left=' + l+',scrollbars=no,menubar=no,toolbar=no,status=no');
    
     
    
    }
    
     
    
    function atLeastOneChecked(form) {
    
     
    
       var inputs = form.getElementsByTagName('input');
    
       var i = inputs.length;
    
       while (i--) {  
    
         
    
          if(inputs[i].checked && !inputs[i].disabled)
    
         
    
             if(confirm("Confermi?.")) {
    
                PopUp();  
                return false;
    
                } else {           
    
                longcall(); 
                return true;
    
                }         
    
       }
    
      
    
       alert("Stop!")
       return false;    
    
     
    
    }
    
     
    
    // ]]>
    
    </script>
    
    </head>
    
    <body>    
    
    <form name=frmTest action="default-2.asp" method=POST onsubmit="return atLeastOneChecked(this)">
    
    
    
    
    <input type=checkbox name=chkParent25 value=21118>
    </p>
    
    
    <input type="image" src="assegnazione_button.gif" border="0"></p>
    
    </form>   
    
    <div id="wait" style="background-color:white;position:absolute;top:240px;left:360px;width:70px;height:50px;visibility:hidden;border: 1px solid black;padding:20px;">
    [img]progressBarLong.gif[/img]
    
    
    Please wait...
    
    </div>
    </body>
    
    </html>

  3. #3
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870
    up

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 © 2025 vBulletin Solutions, Inc. All rights reserved.