Hi
I think this is my 4 or 5th post about the ajax issues with my rails code. But i couldn't rectify my issues sofar.
problem is,
In my pages.html.erb have one text field and button. when i click on that button, the text field value will get into the controller through ajax,so after the function i need to get that value(textfield value) in same page.
page.html.erb
<%= form_tag({:controller => 'bpages',:action => 'add' }, {:method => :post}) do %>
<%= text_field_tag('Bnum' ,nil, :id => "bnum") %>
<%= submit_tag "Add", :id => "addbtn", :class => "addsubmit btn btn-large btn-success" %>
<%end%>
<div class="adddtl"
<strong><%= @number%></strong> added
</div>
Here is my ajax part
header.js
$(".addsubmit").click(function() {
var bnum = $("#bnum").val();
var dataString = 'bnumber='+ bnum;
if(bnum=='' )
{
$('.adderror').fadeIn(300).show();
$('.adderror').fadeOut(3000);
}
else
{
$.ajax({
type: "POST",
data: dataString,
success: function(){
$('.adddtl').fadeIn(200).show();
$(".adddtl").fadeOut(3000);
}
return false;
});
Controller
class BpagesController < ApplicationController
def add
@number = params[:bnumber]
render 'bpages/page'
end
end
After the function add i need to display the value of variable @number in the page.html.erb, for that here i use the render 'bpages/page'. But i didn't that variable.
or any other way to do this..?plz give one solution
Thanks
vishnu