title: Rails submitting a form through ajax and updating the view
body: <p>I want to update a form submit through ajax without reloading the page and update the view according to it. I tried the different methods and failed as i m new to rails.</p>
  
  <p>Here's the situation. </p>
  
  <p>In modal</p>
  
  <pre><code>def new
      @new_entry = current_user.notes.build
      @words = current_user.notes
      @notes_false_list = current_user.notes.where(known: false).order("title").group_by { |note| note.title[0] }
      @notes_true_list = current_user.notes.where(known: true).order("title").group_by { |note| note.title[0] }
    end
  </code></pre>
  
  <p>In view the form code.</p>
  
  <pre><code>&lt;%= form_for @new_entry, :html =&gt; {:class =&gt; 'home-form without-entry clearfix'}  do |f| %&gt;
        &lt;%= f.text_field :title, placeholder: 'Squirrel', autofocus: true, class: 'title-field pull-left' %&gt;
        &lt;%= f.submit '', class: 'btn home-add without-entry' %&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p>The create action</p>
  
  <pre><code>def create
      @new_note = current_user.notes.build(new_note_params)
      if @new_note.save
        @notes_list = current_user.notes.count
        unless @new_note.user.any_entry
          @new_note.user.toggle!(:any_entry) if @notes_list &gt;= 50
          redirect_to root_url
        end
      else
        redirect_to root_url
      end
    end
  </code></pre>
  
  <p>and finally in the view i want to change</p>
  
  <pre><code>&lt;p class="instructions count-instruction text-center"&gt;
        &lt;%= @words.count %&gt;
      &lt;/p&gt;
  </code></pre>
  
  <p>Spent a lot of time updating this with AJAX but failed everytime. Any there to help? Thanks in advance.</p>