title: Insert into MySql database from Javascript window?
body: <p>Merry Christmas all.</p>
  
  <p>I have a calender (main page) that, when a user clicks a date a window (booking window) opens within the calender using javascript showing another php page which has a booking form (booking page).  I have a javascript validation set on the main page and everything is working great.</p>
  
  <p>I don't know if it's too much sherry or just my mind away for Christmas but I can't get my head the following.</p>
  
  <p>When the user clicks the submit the entire page refreshes as it should do on a server side but I'm not sure what I'd need to do so that only that window will refresh instead of the entire page.</p>
  
  <p>Is there another way other than using Javascript to enter the data to MySql?  I'm a tad lost.</p>
  
  <p>Thanks in advance :)</p>
  
  <p>EDIT JAVASCRIPT CODE:-</p>
  
  <pre><code>var date = (thisId.id);
  var hr = new XMLHttpRequest();
  var url = "Scripts/NewBooking.php";
  var vars = "date="+date+"&amp;jobtime="+jobtime;
  var jobtime = "Morning";
  hr.open("POST", url, true);
  hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  hr.onreadystatechange = function() {
      if(hr.readyState == 4 &amp;&amp; hr.status == 200) {
          var return_data = hr.responseText;
          document.getElementById("events").innerHTML = return_data;
      }
  }
  hr.send(vars)
  document.getElementById("events").innerHTML = "processing...";
  </code></pre>