Can't get a FORM to submit remotely in Rails 3.0.3?


I am using Rails 3.0.3 with jQuery ujs.

I want to send a form remotely. The view template
**mains/index.html.erb** containing the form looks as follows:

<%= form_tag :remote => true, :controller => "mains", :action =>
"search", :format => :js do %>
<div class="dialog">
<tr class="prop">
<td valign="top" class="name">
<%= label_tag(:location_start, "Location Start:") %>
<td valign="top">
<%= text_field_tag(:location_start) %>
<div class="buttons">
<span class="button"><%= submit_tag("Search") %></span>
<% end %>

The controller mains_controller.rb looks as follows (removed
unnecessary stuff):

class MainsController < ApplicationController

def index
respond_to do |format|
  format.html # index.html.erb

def search
respond_to do |format|
  format.js { render :template => 'mains/search.js.erb'}


The view template **mains/search.js.erb** has the following content:


I am using search.js.erb instead of search.js.rjs due to instructions in
chapter "26.4 Write Less and Do More with JQuery" in Agile Web
Development with Rails (4h edition). I also added :format => :js due

When I call and submit the form,
it's actually not submitted remotely, but the browser loads instead. The browser
outputs `$('#search').html("<h1>Headline</h1>");`, instead of executing
the JavaScript by replacing div#search with `<h1>Headline</h1>` given.

I tried to find a solution but wasen't successful so far... Could anyone

i think changing the form_tag to

form_tag {:controller => ‘mains’, :action => ‘search’, :format => :js}, :remote => true do

should work. The brackets are there to separate the url_for options with the html_options.