Rendering a partial (through Ajax) and it's 'hanging'

Hi

I have some HTML code for form that submits a name and I find that name
in the database and ‘preview’ the info.

In the console and from tailling the logs the player is being returned.

When it start to render my partial, via a call to an .rjs it just hangs
forever.

Some Code:

<% form_remote_tag :url => { :controller => :rhp_draft, :action =>
:get_player } do %>
Player to Draft: <%= text_field_with_auto_complete :nhl_stat,
:player_name %> <%= submit_tag “Preview player” %>
<% end %>


Player summary....

*** NOTE: The Autocomplete stuff works… it’s once I click “preview
player” that I have my issues.

Controller code:
def get_player
search = params[:nhl_stat][:player_name]
@player = NhlStat.find_by_player_name( search )
end

RJS template and Partial that it’s using.

get_player.rjs
page.replace_html( “player_summary”, :partial => “nhl_player”, :object
=> @player )

_nhl_player.rhtml

Name: <%= @player.player_name %> Team: <%= @player.team %> Pos: <%= @player.pos %> Salary: <%= @player.salary %>

Message from firebug and my log files.

Firebug:

Looking at the Inspect tag / Console I see that the post information is
stuck on “loading…”

Log files:

Processing RhpDraftController#get_player (for 127.0.0.1 at 2007-09-11
17:09:44) [POST]
Session ID: 537556154e6fdc2eed1cb4265c922dec
Parameters: {“commit”=>“Preview player”, “action”=>“get_player”,
“nhl_stat”=>{“player_name”=>“John Erskine”}, “controller”=>“rhp_draft”}

NhlStat Columns (0.019004) SHOW FIELDS FROM nhl_stats
NhlStat Load (0.003660) SELECT * FROM nhl_stats WHERE
(nhl_stats.player_name = ‘John Erskine’) LIMIT 1
Rendering rhp_draft/get_player

Notice the last line… it just hangs there.

Any help would be appreciated. Thanks!

Just a quick observation, in your form helper:

<% form_remote_tag :url => { :controller => :rhp_draft, :action =>
:get_player } do %>

You don’t have the … do -%>. That “-” character has given me grief
in the past. Just a small observation but sometimes it is the little
things that cause all the problems.

~S

Shandy N. wrote:

Just a quick observation, in your form helper:

<% form_remote_tag :url => { :controller => :rhp_draft, :action =>
:get_player } do %>

You don’t have the … do -%>. That “-” character has given me grief
in the past. Just a small observation but sometimes it is the little
things that cause all the problems.

~S

I"ll add it, but I thought that the little - char was only to prevent a
linefeed after / before the tag.

Jean N. wrote:

I"ll add it, but I thought that the little - char was only to prevent a
linefeed after / before the tag.

added it and no change, still hangs.

Jean N. wrote:

Jean N. wrote:

I"ll add it, but I thought that the little - char was only to prevent a
linefeed after / before the tag.

added it and no change, still hangs.

Found the problem… (Rails ‘nuances’ are starting to slowly get to me)

THIS DOES NOT WORK!! (As I posted above)

<% form_remote_tag :url => { :controller => :rhp_draft, :action =>
:get_player } do %>
Player to Draft: <%= text_field_with_auto_complete :nhl_stat,
:player_name %> <%= submit_tag “Preview player” %>
<% end %>


Player summary....

THIS DOES!!
<% form_remote_tag :url => { :controller => :rhp_draft, :action =>
:get_player } do %> Player to Draft: <%= text_field_with_auto_complete
:nhl_stat,
:player_name %> <%= submit_tag “Preview player” %>
<% end %>


Player summary....

The diff… no line feed after the “do %> Player to Draft” piece of code
in the html form being submitted.

If I put the text on the following line, the render action hang forever.

Double You, Tee, Eff.

:slight_smile:

Hi,

It is great you got your code to work, but experience suggests that
you did not
fix the real problem. While Rails idiosyncrasies have gotten to me, it
is
highly unlikely that changing the second line to be after the first is
the issue.
What has helped me before is to delete the first two lines and retype
them.
You might have a special character lurking.

Gordon

Just an additional suggestion for debugging this kind of thing, since
it is an asynchronous request you don’t see what is really happening
in the dev log. But if you run firebug in firefox you will be able to
see the ajax request being made in the debugging console and will most
likely be able to see what error message is coming back.

Paul