title: How safe is redirect via javascript?
body: <p>I have developed a Rails app and now I'm trying to improve its security. There are some ajax on it and as I don't have much experience with jQuery and on one of the ajax requests, I have to redirect the user via javascript, is it a good practice? I would like to know if it's safe the implementation below and what is the risk that my app could be suffering too:</p>
  
  <pre><code>success: function(callback) {
    if (callback.status == true) {
      if (event.target.id == 'radar_occurrences')
        window.location.href = '/radar/all'
      else
        window.location.href = '/radar/list'
      }
    else {
      $("body").before("&lt;p class='error'&gt;Failure message.&lt;/p&gt;");
      flashError();
    }
  }
  </code></pre>
  
  <p>Thanks!</p>