title: Calling JavaScript function after updating table with PHP
body: <p>I have a simple website that uses JavaScript to collect user input and sends data to PHP script (script is an external php file) via AJAX request. PHP script updates database with this information.</p>
  
  <p>Now, i have a JS function on my website that i want to call only after PHP script is sucessfuly run and database updated. I don't need any data from database or PHP script, i only want to make sure that database is updated before calling this Javascript function.</p>
  
  <p>This is what AJAX request looks like:</p>
  
  <pre><code>function ajax_post(){
    if (typeof featureId !== 'undefined') {
      // Create our XMLHttpRequest object
      var hr = new XMLHttpRequest();
      // Create some variables we need to send to our PHP file
      var url = "parse_file.php";
      var fn = featureId;
      var vars = "featureId="+fn;
      hr.open("POST", url, true);
      // Set content type header information for sending url encoded variables in the request
      hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      // Access the onreadystatechange event for the XMLHttpRequest object
      hr.onreadystatechange = function() {
          if(hr.readyState == 4 &amp;&amp; hr.status == 200) {
              var return_data = hr.responseText;
              document.getElementById("status").innerHTML = return_data;
          }
      }
      // Send the data to PHP now... and wait for response to update the status div
      hr.send(vars); // Actually execute the request
      document.getElementById("status").innerHTML = "processing...";
      hilites.destroyFeatures();
      featureId = undefined;
    }
    else {
      window.alert("Select polygon first");
    }
  }
  </code></pre>
  
  <p>What is the best way to do this? Some examples would really help.</p>