title: Failed AJAX & PHP communication on Localhost WAMP Configuration
body: <p>First off I am new to AJAX, this is my first attempt at using AJAX with PHP.  The problem I have encountered is that although my XMLHttpRequest state successfully changes its state to 4, ie: complete, the responseText and all other response types are "" (empty).  </p>
  
  <p>I have tried really simple versions of my code and recently tried a copy of W3Schools AJAX &amp; PHP example <a href="http://www.w3schools.com/ajax/ajax_aspphp.asp" rel="nofollow">http://www.w3schools.com/ajax/ajax_aspphp.asp</a> which also failed to return anything.  This leads me to believe it may be a configuration problem but I dont know where to go from here?  Any suggestions anyone?</p>
  
  <p>This is a section of my js which applies to the AJAX PHP Comms:</p>
  
  <pre><code>$("#submitButton").click(function() {
      alert("The button has been clicked")
      if(($("#title").val().length &lt; 3 ) || ($("#description").val().length &lt; 3 ))
      {
          alert("Title and Description must be 3 characters or more!");
      }
      else
      {
              var ajaxRequest;
  
              try{
                  // Opera 8.0+, Firefox, Safari
                  ajaxRequest = new XMLHttpRequest();
              } catch (e){
                  // Internet Explorer Browsers
                  alert("THE PROBLEM WAS IE " + e);
                  try{
                      ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
                  } catch (e) {
                      alert("THE PROBLEM WAS second " + e);
                      try{
                          ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                      } catch (e){
                          // Something went wrong
                          alert("Your browser broke!");
                          return false;
                      }
                  }
              }   
  
              // receive data sent from the server
              ajaxRequest.onreadystatechange = function(){
                  if(ajaxRequest.readyState == 4){
                      // Get the data from the server's response
                      var test = ajaxRequest.responseText; 
                      alert(test);
                      //console.log(xmlHttp);
                      console.log(ajaxRequest);
                  }
              }
  
              //Variables
              var title =$("#title").val();
              var description =$("#description").val();
              var url = $("#url").val();
  
              ajaxRequest.open('GET','http://localhost/TestPHP/Model/AddNewVideo.php');
              try {
                  ajaxRequest.send();
              }
              catch(e) {
                  alert("THE PROBLEM WAS " + e);
              }   
      }
  });
  </code></pre>
  
  <p>Here is my PHP code.  The PHP has not been tested on its own to ensure the SQL query works, but it doesnt even work if I just reduce it to echo 'hello world'.</p>
  
  <pre><code>    &lt;?PHP
  header('Access-Control-Allow-Origin: *');
  //Connect to dBase
  include("mysql_connect.php");
  if ($_SERVER['REQUEST_METHOD'] == 'POST') {
      echo 'POSTed Method';
    }
  if ($_SERVER['REQUEST_METHOD'] == 'GET') {
      echo 'GET Method';
    }
  
  
  //Debugging
  ini_set('display_errors', 'On');
  error_reporting(E_ALL | E_STRICT);
  
  //Gather Variables
  echo $title = mysql_real_escape_string($_GET["TITLE"]);
  $description = mysql_real_escape_string($_GET["DESCRIPTION"]);
  $url = mysql_real_escape_string($_GET["URL"]);
  
  //Insert new query
  mysql_query('INSERT INTO video VALUES($title, $description, $url') or die(mysql_error());
  
  
  //Close the DBase
  mysql_close($connect);
  
  echo $description;
  ?&gt;
  </code></pre>
  
  <p>My Update and enhanced version of js using JQuery;</p>
  
  <pre><code>$("#submitButton").click(function(event) {
          alert("The button has been clicked")
          if(($("#title").val().length &lt; 3 ) || ($("#description").val().length &lt; 3 ))
      {
          alert("Title and Description must be 3 characters or more!");
      }
      else
      {
              // Variables to pass
              var $form = $("#AddVideoForm"),
              // Gather all fields 
              $inputs = $form.find("input, select, button, textarea"),
              // serialize the data in the form
              serializedData = $form.serialize();
  
  
              try
              {
                  //JQuery Based AJAX HTTP Request
                  $.ajax({
                      url: "http://localhost/TestPHP/Model/AddNewVideo.php",
                      type: "POST",
                      data: serializedData,
                      success: function(response, textStatus, jqXHR){
                      // Show success
                      alert("Wonderful It worked");
                      console.log("Hooray, it worked!");
                      },
                      // callback handler that will be called on error
                      error: function(jqXHR, textStatus, errorThrown){
                      // log the error to the console
                      console.log("The following error occured: "+ textStatus, errorThrown)
                      },
                      complete: function(){
                      // Display Completed message
                      alert("Totally Completed!  Hoorah!");
                      }
                  });
              } 
              catch (e)
              {
                  alert("THE PROBLEM WAS " + e);
              }
              event.preventDefault();
      }
  });'
  </code></pre>