-
-
Save axsuul/1804968 to your computer and use it in GitHub Desktop.
sending values from javascript into ruby injection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="button" onclick="myfunction()" value="NEWEdit" /> | |
<script language="javascript" type="text/javascript"> | |
$(function() { | |
$(document).on('click', '#edit', function() { | |
$('#he').text($('#posts').data('count')); | |
}); | |
}); | |
</script> | |
<div id="posts" data-count="<%= params[:count] %>"> | |
<h2 id='he'></h2> | |
<input type="button" id="edit" value="NEWEdit" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ApplicationController | |
# GET /posts | |
# GET /posts.json | |
def index | |
@posts = Post.all | |
@val=params[:count].to_i | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render :json => @posts } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment