Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


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>";