2017-09-19 98 views
0

說我有下面的代碼:JSON解析變量內的內容?

var xmlhttp = new XMLHttpRequest(); 
    xmlhttp.onreadystatechange = function() { 
     if (this.readyState == 4 && this.status == 200) { 
      var responses = JSON.parse(this.responseText); 
      var email = document.getElementById("email").value; 
      var passwordIs = responses.email; // email should be replaced with the user's input value; 
      document.write(passwordIs); 
     } 
    }; 
xmlhttp.open("GET","https://example.com", true); 
xmlhttp.send(); 

我怎樣才能使它運行,這樣當用戶將在電子郵件中,在可變passwordIs電子郵件獲取與輸入取代?

說得簡單來說,當用戶進入[email protected],變量passwordIs應該「看」這樣的:[email protected]相反,它是「看」的responses.email

回答