I'm trying to update vote count via ajax once user has voted. My code works fine except for something which should be pretty basic, which is showing the new total number of votes.

My javascript has the following code:

```
    var voteCount = "<%= @trip.total_up_votes %>";
    ...
    $.ajax({
    ...
    success: function() {
            console.log("SAVED TO VOTES TABLE SUCCESSFULLY");
            $('#voting_up').html(voteCount);
        },
    ...
    });

```

Once the vote link has been clicked, everything gets added to the table fine except it shows the new vote count as <%= @trip.total\_up\_votes %> i.e. as a string. The total\_up\_votes method simply counts the number of up votes from the votes table. This works fine when the page is first loaded or when it's refreshed.

I've tried escape\_javascript and many other suggestions after trawling through the internet but I'm still stuck. Could someone help please?

EDIT:
As requested, my votes\_controller does this:

```
    def cast_vote()
        @vote = Vote.where("user_id = ? AND trip_id = ?", current_user, params[:id]).first || Vote.new(:user_id => current_user)  
        @vote.vote_type = params[:vote_type]
        @vote.user_id = params[:user_id]
        @vote.trip_id = params[:id]

        respond_to do |format|
           @vote.save
           format.html {redirect_to :back}
           format.js
        end
    end

```