Topic: AJAX form works in IE, not in firefox...any clues?

<div id="newTaskDiv" style="display: none; float: left; width: 100%">
<%=  form_remote_tag :update => 'tasksdiv',
  :url => {  :action => "newtask" }, :position => "bottom" %>
<div class="layer5"><textarea name="task[description]" rows="5" style="width:90%"></textarea></div>
<div class="layer5"><%= @task.description %></div>
<div class="layer5"><%= @task.description %></div>
<div class="layer5"><%= @task.description %></div>
<%= hidden_field :job, :id %>
<%= submit_tag "Create" %>
<%= end_form_tag %>
</div>

and the action newtask looks like:

def newtask
@task = Task.new(params[:task])
@task.job_id = params[:job][:id]
@successful = @task.save
render :partial => 'task'
end

and the partial looks like thus:
<div id="task<%= @task.id %>" >
<div class="layer5"><%= @task.description %></div>
<div class="layer5"><%= @task.description %></div>
<div class="layer5"><%= @task.description %></div>
<div class="layer5"><%= @task.description %></div>
</div>

In firefox, the form displays correctly, but fails to add the new row to the table. When the page is refreshed the new row is there.

In IE, no refresh is required, as I had expected the code to do.

Is this a bug? have I missed something really obivous?

Cheers

Miles

Re: AJAX form works in IE, not in firefox...any clues?

Try downloading the FireBug plugin for firefox. It allows you to see what's going on behind the scenes of an AJAX request.

Are you using any puts/print statements in the newtask action? Those have been known to break AJAX. Also, is anything in the development.log when doing the AJAX request with firefox? This will tell you if the server is receiving a request.

Railscasts - Free Ruby on Rails Screencasts

Re: AJAX form works in IE, not in firefox...any clues?

Hi, cheers for the FireBug pointer, it's amazing.

secondly, it was a really simple problem, that is down to my poor coding.

Firefox is case sensitive in it's getElementById spec. IE is not.

 <%=  form_remote_tag :update => 'tasksdiv',
   :url => {  :action => "newtask" }, :position => "bottom" %>

the div was actually called 'tasksDiv'.

Sorry

Miles

Last edited by mileswilson (2007-01-26 07:57:38)