title: Render a view in rails via AJAX and controller
body: <p>I have this JS code in my application.js:</p>
  
  <pre><code>  $(document).ready(function(){
          var kraken_btc_eur_old = 0;
  
          setInterval(function(){
  
              $.get('https://api.kraken.com/0/public/Ticker?pair=XXBTZEUR', function(data){
  
                  var kraken_btc_eur = data.result.XXBTZEUR.c[0];
                  kraken_btc_eur_old = kraken_btc_eur;
                  $(".kraken_btc_eur").text(kraken_btc_eur);
  
              });
  
              $.ajax({
                type: "POST",
                url: "/bets",
                data: { parameter: kraken_btc_eur_old },
                success: function (data) {
  
                 }        
              });
  
          }, 10000);
  
      });
  </code></pre>
  
  <p>So far so good, every 10 sec the page display the new value fetch from the API and place it to the corresponding class in the HTML without any page refresh.
  My problem is with the AJAX request. I can see that in the rails console that every 10 sec the post request hit the create action in my controller and that the code is executed accordingly:</p>
  
  <pre><code>def create
      @bet = Bet.new
      @bet.base_price = params["parameter"]
      @bet.save  
      Bet.first.destroy
  
      @bets = Bet.all
      @bet_last = Bet.last
  
      #render :js =&gt; "window.location = '#{root_path}'"
      #redirect_to "index"
      #render :inline =&gt; "&lt;% @bets.each do |b| %&gt;&lt;p&gt;&lt;%= b.id %&gt;&lt;p&gt;&lt;% end %&gt;"
  
    end
  </code></pre>
  
  <p>However I do not manage to update the html view with the new values without having to refresh the page. Because every 10 sec new bets are created (AJAX), I want them to appear automatically in the page without any refresh to be done.
  I tried to render in different ways in my create action, I realized that there are documents created in my browser console under ressources -> XHR with the updated htm but I do not manage to have that replace by the showed one without any refresh.</p>