rail ajax remote form to update text field upon submission

All I want to do is update a text field on my page with a value when my Rails remote form is submitted.

All the source code be found at github here https://github.com/iamliamnorton/fasdac

The form is on the index page...

Controller code...

def index

  @calculator = Calculator.new(params[:calculator])
  if @calculator.valid?
    respond_to do |format|
      format.html { redirect_to calculator_path(:calculator => params[:calculator]), :notice => 'Calculation was successfully completed.' }
    respond_to do |format|
      format.html { redirect_to calculator_path(:calculator => params[:calculator]), :alert => "Calculation was not successfully completed. #{@calculator.errors.full_messages.to_sentence}" }

My input form

<%= form_for(@calculator, :url => calculator_path, :remote => true) do |f| %>
<% end %>

And the index.js.erb

$("#result").value = "SUCCESS!";

I'm trying to update a input text field with name and id 'result'. I cannot get this working, I've tried many different variants in the index.js.erb but cannot get it working. What am I doing wrong?

It looks like the data is being sent to the controller as I can see in the server console

Processing by CalculatorController#index as JS

But I can't get the text area to update




Need Your Help

How to add data from db.selectAll Please check it agian

android listview

Now i try to use adapter . But i dont understand how to set value from data .Becuase in friends = db.selectall ,value in friend have 3 value(fname,lname,nickname).So my question is How to set

Wrong logarithm of BigInteger when size of BigInteger exceeds ¼ gigabyte

c# .net biginteger logarithm bcl

When I have a BigInteger whose size exceeds 2 gigabits (that's ¼ gigabyte; I found this threshold by trial and error), the logarithm method gives a wrong answer. This simple code illustrates: