jquery - rails 4.0.1 can't show ruby code in view via javascript ajax -


Once user voted I am trying to update vote count through AJAX Except works fine, which should be very basic, showing the total number of total votes.

My JavaScript has the following code:

  var voteCount = "& lt;% = @ trip.total_up_votes%>"; ... $ .ajax ({... success: work () {console.log ("voted to vote successfully"); $ ('# poll' _p ''). Html (vote);} , ...});  

Once the click has been clicked on the link, everything is added to the table, apart from this new vote count as the string of & lt;% = @ trip.total_up_votes%> Shows in The Total_up_wot method simply calculates the number of votes from the Vote table. This work is fine when the page loads for the first time or when it is refreshed.

After passing through the internet I have tried escape_javascript and many other suggestions, but I am still stuck.

  def cast_vote () @vote = Vote. Where ("user_id =? AND trip_id =?", Current_user, param [[id]). First || Vote: New (: user_id = & gt; current_user) @move Vita_type = param [: Vote_type] @ Votes.user_id = paras [: user_id] @vototype_id = param [: id] do not respond_to. Format | @ Votes.Save format.html {redirect_to: back} format.js End and  

Have you tried quitting?

  var match count = & lt;% = @ trip.total_up_votes%>; ... $ .ajax ({... success: work () {console.log ("voted to vote successfully"); $ ('# poll' _p ''). Html (vote);} , ...});  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -