Visualizzazione dei risultati da 1 a 10 su 11

Discussione: Login con Ajax

Visualizzazione discussione

  1. #9
    Ho modificato queste due parti di codice. Ora la console di Chrome mi da questo errore:
    GET http://localhost/.. ./index.php?checkusr=john 404 (Not Found) javascript.js:477
    checkUsr javascript.js:477
    onchange index.php:82


    XHR finished loading: "http://localhost/.. ./index.php?checkusr=john". javascript.js:477
    checkUsrjavascript.js:477
    onchange




    JAVASCRIPT
    codice:
    function setXMLHttpRequest() {
       var xhr = null;
       //Browser standard con supporto nativo (per tutti i browser tranne Explorer)
       if(window.XMLHttpRequest) {
         xhr = new XMLHttpRequest();
       }
       //MSIE 6 con ActiveX (per Explorer)
       else if(window.ActiveXObject) {
         xhr = new ActiveXObject("Microsoft.XMLHTTP");
       }
       return xhr;
    }
    
    
    
    
    var xhrObj = setXMLHttpRequest();
    
    
    
    
    function checkUsr(usr) {
       var url = "public/index.php?checkusr=" + usr;
       //var url = "../indexSignup.php?checkusr=" + usr;
       xhrObj.open("GET", url, true);
       xhrObj.onreadystatechange = updateUsr;
       xhrObj.send(null); RIGA 477
    }
    
    
    
    
    function updateUsr() {
       if(xhrObj.readyState === 4) {
          var risp = xhrObj.responseText;
          document.getElementById("reg_username").innerHTML = risp;
       }
    }

    PHP
    codice:
       public function checkAjax() {
          if(isset($_GET['checkusr'])){
              $usr = $_GET['checkusr'];
              //$risp = $this->model->compareUsr($usr);
              $this->user = $this->userRepository->findByUsername($usr);
              if($this->user === NULL) {
                $this->ajax['succ'] = "Username disponibile.";
                $this->view->setData('ajax', $this->ajax);              
              }
              else if($risp  > 0) {
                $this->ajax['err'] = "Username non disponibile.";
                $this->view->setData('ajax', $this->ajax); 
              }
          }
       }   
       
       public function invoke() {
          if(isset($_GET['checkusr'])) {
             $this->checkAjax();
             //session_destroy();
          }       
          $this->checkLogin(); //Esegue i controlli sui dati del form di login
          $this->checkSignup();
          return $this->view;
       }
    Ultima modifica di stefano86; 07-02-2014 a 19:45

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.