title: How to make page reload with Javascript, or Ruby on rails
body: <p>I am trying to make my page reload after sorting through the new position, either through Javascript or in the Ruby on Rails code.</p>
  
  <pre><code>$("#serialize").click -&gt;
  c = set: JSON.stringify($("#sortable").nestedSortable("toHierarchy",
    startDepthCount: 0
  ))
  $.post "savesort", c, $("#output").html("&lt;p id=\"flash_notice\"&gt;Saved Successfully&lt;/p&gt;")
  false
  </code></pre>
  
  <p>I'm thinking of adding it here</p>
  
  <pre><code>$.post "savesort", c, $("#output").html("&lt;p id=\"flash_notice\"&gt;Saved Successfully&lt;/p&gt;")
  window.location.reload(false); 
  false
  </code></pre>
  
  <p>But it seems like that messes up the order. Here is my rails code</p>
  
  <pre><code>class SiteController &lt; ApplicationController
  
  def savesort
  neworder = JSON.parse(params[:set])
  prev_item = nil
  neworder.each do |item|
    dbitem = Category.find(item['id'])
    prev_item.nil? ? dbitem.move_to_root : dbitem.move_to_right_of(prev_item)
    sort_children(item, dbitem) unless item['children'].nil?
    prev_item = dbitem   
  end
  Category.rebuild!
  render :nothing =&gt; true
    end
  end
  </code></pre>
  
  <p>I am also thinking about change render :nothing => true to redirect_to root_url but that doesn't seem to work either. </p>
  
  <p>here is my Routes.rb (Shortened for the sake of space)</p>
  
  <pre><code>locksmithing::Application.routes.draw do
    get "site/home"
    match "/savesort" =&gt; 'site#savesort'
      root to: 'site#home'
  end
  </code></pre>
  
  <p>So, where should I add the code to refresh the page? Javascript or in the Site Controller? or is there another solution? Thanks in advance.</p>