function metricReady(url)
{
  ready = false
  $.ajax({
    async: false,
    type: "GET",
        url: url,
        success: function(msg, textStatus){
        ready = true;
      },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
        ready = false;
      }
    });
  return ready;
}

function checkForResult(url)
{
  if(metricReady(url)) {
    // Page responded immediately, we're all set
  }
  else {
    // Page didn't respond, we'll poll
    $("div.waiting").show("fast");
    interval = 3000; // in milliseconds
    window.setInterval(
                       function() {
                         if(metricReady(url)){
                           window.location.reload();
                         }
                         else{
                           // still isn't ready, so keep iterating
                         }
                       },
                       interval);
  }
}

$(document).ready(function() {
    // Add other AJAX goodness in here
  });



