Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


responseText AJAX

Hy all i am learning AJAX and i am able to send request but i m not getting any thing print on my index.php in div tag with id #msg

here is my all scripts which i use in my localserver

    <title>Ajax form submission</title>
    <link rel="stylesheet" type="text/css" href="normalize.css">
    <link rel="stylesheet" type="text/css" href="style.css">

  <!--sign up -->
     <form action = "register.php" method="post">
        <input type="text" name="firstName" id="firstName" onkeyup="validate('firstName',this.value)" placeholder="Enter your firstname">
          <div id="msg"></div>
        <input type="text" name="lastName" id="lastName" placeholder="Enter your lastname">

          <input type="text" name="userName" id="userName" placeholder="Enter your username">

          <input type="password" name="password" id="password" placeholder="Enter your password">

          <input type="password" name="con_password" id="con_password" placeholder="Confirm your password">

          <input type="button" class="sign" name="signup" value="signup" onclick="checkform">
     <script src="js/script.js"></script>
function validate(field,value){

    var request; 

      request = new XMLHttpRequest(); request(IE7+,other browsers)
       request = new ActiveXObject("Microsft.XMLHTTP")

    //request state
    request.onreadystatechange = function(){
        if(request.readystate == 4 && request.status == 200){

    request.open("GET","validation.php?field=" + field + "&query=" + value);

  echo "<span>Hey</span>";