Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    [AJAX] Firebug strano comportamento ....

    Ciao.
    Ho questo script:
    index.php
    Codice PHP:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <
    script language="JavaScript" type="text/JavaScript">
    /** XHConn - Simple XMLHTTP Interface - [email]bfults@gmail.com[/email] - 2005-04-08        **
     ** Code licensed under Creative Commons Attribution-ShareAlike License      **
     ** [url]http://creativecommons.org/licenses/by-sa/2.0/[/url] */
    function XHConn(){
      var 
    xmlhttpbComplete false;
      try { 
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
      catch (
    e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
      catch (
    e) { try { xmlhttp = new XMLHttpRequest(); }
      catch (
    e) { xmlhttp false; }}}
      if (!
    xmlhttp) return null;
      
    this.connect = function(sURLsMethodsVarsfnDone){
        if (!
    xmlhttp) return false;
        
    bComplete false;
        
    sMethod sMethod.toUpperCase();
        try {
          if (
    sMethod == "GET"){
            
    xmlhttp.open(sMethodsURL+"?"+sVarstrue);
            
    sVars "";
          }
          else{
            
    xmlhttp.open(sMethodsURLtrue);
            
    xmlhttp.setRequestHeader("Method""POST "+sURL+" HTTP/1.1");
            
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
          }
          
    xmlhttp.onreadystatechange = function(){
            if (
    xmlhttp.readyState == && !bComplete){
              
    bComplete true;
              
    fnDone(xmlhttp);
            }};
          
    xmlhttp.send(sVars);
        }
        catch(
    z) { return false; }
        return 
    true;
      };
      return 
    this;
    }

    function 
    myTest(xhr){
        
    alert(xhr.responseText);
    }

    var 
    reqXHConn();
    window.onload= function(){
        var 
    target document.getElementById('my-buttom');
        if(!
    target){return;}
        
    target.onclick=function(){
        var 
    inputValue document.getElementById('my-text').value;
        var 
    postVar'cat_title='+encodeURIComponent(inputValue);
        
    alert(postVar);
        
    req.connect('test.php','POST',postVar,myTest);
        }
    }
    </script>
    <body>
    <form action="" method="post" name="frm">
    <input id="my-text" name="my_test" type="text">

    <input id="my-buttom" name="my_buttom" type="button" value="insert">
    </form>

    </body>
    </html> 
    test.php
    Codice PHP:
    <?php 
    if(isset($_POST['cat_title'])){
        echo 
    $_POST['cat_title'];
    }
    else{
        echo 
    "Watch out";
    }
    ?>
    Bene provatelo se ne avete voglia
    Lo script fa quello che ci si aspetta
    Se apro Firebug nel reparto Net trovo le mie belle
    variabili (Post cat_title mioinput Response mioinput) ma se invece dopo averlo aperto faccio partire
    un'altra request trovo vuoto Post e nella Response Watch out ma nel mio debug vedo mioinput
    ho preso un colpo di sole o cosa


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  2. #2
    non so se è solo questo ...
    codice:
    var req= XHConn();
    da cambiare con
    codice:
    var req = new XHConn();
    ma in generale lascerei perdere scripts inerenti Ajax del 2005 ... ad esempio:
    codice:
    if (xmlhttp.readyState == 4 && !bComplete)
    non ha senso, bComplete quando readyState è 4 non può che essere false, il tizio l'ha confuso con readyState 3 perchè a valore 4 non esistono altre chiamate alla proprietà onreadystatechange
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

  3. #3



    ma in generale lascerei perdere scripts inerenti Ajax del 2005 ... ad esempio:
    Classette + recenti possibilmente con lo stesso
    comportamento o suggerimenti per renderla +
    stabile.


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  4. #4
    Si ma PP perchè Firebug dice una cosa
    e il mio alert un altra riPP




    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  5. #5
    Cambiando motore la cosa
    non cambia:

    Codice PHP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <
    script language="JavaScript" type="text/JavaScript">
     var 
    http_request false;
       function 
    makePOSTRequest(urlparameters) {
          
    http_request false;
          if (
    window.XMLHttpRequest) { // Mozilla, Safari,...
             
    http_request = new XMLHttpRequest();
             if (
    http_request.overrideMimeType) {
                 
    // set type accordingly to anticipated content type
                //http_request.overrideMimeType('text/xml');
                
    http_request.overrideMimeType('text/html');

             }
          } else if (
    window.ActiveXObject) { // IE
             
    try {
                
    http_request = new ActiveXObject("Msxml2.XMLHTTP");
             } catch (
    e) {
                try {
                   
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (
    e) {}
             }
          }
          if (!
    http_request) {
             
    alert('Cannot create XMLHTTP instance');
             return 
    false;
          }
          
          
    http_request.onreadystatechange alertContents;
          
    http_request.open('POST'urltrue);
          
    http_request.setRequestHeader("Content-type""application/x-www-form-urlencoded");
          
    http_request.setRequestHeader("Content-length"parameters.length);
          
    http_request.setRequestHeader("Connection""close");
          
    http_request.send(parameters);
       }

       function 
    alertContents() {
             
    document.getElementById('myspan').innerHTML ='loading ......';
          if (
    http_request.readyState == 4) {
             if (
    http_request.status == 200) {
                
    //alert(http_request.responseText);
                
    result http_request.responseText;
                
    document.getElementById('myspan').innerHTML result;            
             } else {
                
    alert('There was a problem with the request.');
             }
          }
       }
    window.onload= function(){ 
        var 
    target document.getElementById('my-buttom'); 
        if(!
    target){return;} 
        
    target.onclick=function(){ 
        var 
    inputValue document.getElementById('my-text').value
        var 
    postVar'cat_title='+encodeURIComponent(inputValue); 
        
    //alert(postVar); 
         
    makePOSTRequest('post.php'postVar);
        } 
    }
    </script>

    </head>

    <body>
    <form action="" method="post" name="frm"> 
    <input id="my-text" name="my_test" type="text">
     
    <input id="my-buttom" name="my_buttom" type="button" value="insert">
    </form>



    Server-Response:

    <hr>
    <span name="myspan" id="myspan"></span>
    <hr>
    </body>
    </html> 
    Firebug da watch out lo script mioinput ?

    Vi risulta questo comportamento o no ?

    Comincio a pensare che ho Firebug bacato

    riportao le versioni

    FF 2.0.0.5

    Firebug 1.05


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  6. #6
    Originariamente inviato da whisher
    Cambiando motore la cosa
    non cambia
    ma dove li trovi ?

    comunque sia,

    1 - FireFox si è aggiornato ieri, se non erro
    2 - FireBug non è il padre eterno ... fosse stato perfetto l'ideatore non avrebbe chiesto aiuto per continuare a svilupparlo ...

    ergo fidati dei risultati sul client, FireBug o non FireBug, oppure vedi se c'è un aggiornamento per FF 2.0.5
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

  7. #7
    Mi hai dato il buongiorno


    ma dove li trovi ?
    Hai ragione è il primo snippet che avevo alla
    mano per fare una riprova immagino che
    hai trasalito vedendo http_request globale


    Grazie molte.


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

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.