title: refresh page after jquery ajax
body: <p>I am trying to refresh the page after a jQuery AJAX call. It appears that the page is refreshing (only sometimes) before all the data has been transmitted. Can anyone see why by this snippet below. I have the refresh code in the success function so I am confused.</p>
  
  <p>I tried adding <code>async = false</code> and that didn't seem to work either.</p>
  
  <pre><code>function sendRating(rating, reload_on_return) {
  
  $.ajax({
      type: "POST",
      dataType: 'json',
      url: window.url_root + cid + "/",
      data: {
          "rating": rating.r2 / 100.0
      },
      success: function(data) {
          if (data.hasOwnProperty('success')) {
              console.log("data was sent!");
  
              if (reload_on_return) {
                      location.reload();
  
              }
  
          }
      },
      error: function() {
          console.log("Data didn't get sent!!");
      }
  })
  </code></pre>