title: change db value AJAX PHP JS
body: <p>I want for user to click a button to delete de div, and for it to no longer show on he webpage i want to change a value in my db so the webpage knows it was deleted and no longer appears in the 'newsfeed'. It does delete the div , but doesnt do anything to the DB. </p>
  
  <p>JS code:</p>
  
  <pre><code>var xmlHttp = createXmlHttpRequestObject();
  
  function createXmlHttpRequestObject() {
  var xmlHttp;
  
  //for IE
      if(window.ActiveXObject) {
          try{
              xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");//THIS object is the heart of AJAX for users using IE
          }
          catch(e) {
              alert("Connection Error1");
              xmlHttp = false;
          }
      }
      else {
          try {
              xmlHttp = new XMLHttpRequest(); //THIS object is the heart of AJAX
          }
          catch(e) {
              alert("Connection Error2");
              xmlHttp = false;
          }
      }
  
      if(!xmlHttp) {
          alert("Connection Error");
      }
      else {
          return xmlHttp;
      }
  }
  
  function deletePreview(id){
      xmlHttp.open("GET","entOfferDeletePreview.php?id=" + id + "&amp;t=" +                Math.random(),true);
      xmlHttp.send(null);
      alert(id);
  }
  
  function removeDummy(id) {
      var elem = document.getElementById(id);
      elem.parentNode.removeChild(elem);
  }
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>&lt;?php
  include('classes/dbConnection.php');
  
  $link = new dbConnection;
  
  $id = $_GET['id'];
  
  $query = 'UPDATE entoffers SET preview = 1 WHERE id = "$id" ';
  $res = $link-&gt;query($query);
  if($res){
      echo '&lt;script&gt;alert("done");&lt;/script&gt;';
  }
  ?&gt;
  </code></pre>