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

**URL:** <https://www.ruby-forum.com/t/rendering-a-partial-through-ajax-and-its-hanging/114376>\
**Category:** Rails\
**Created:** [September 11, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/rendering-a-partial-through-ajax-and-its-hanging/114376 "2007-09-11T23:17:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [September 11, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/rendering-a-partial-through-ajax-and-its-hanging/114376/1 "2007-09-11T23:17:50Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [September 11, 2007, 11:23pm UTC](https://www.ruby-forum.com/t/rendering-a-partial-through-ajax-and-its-hanging/114376/2 "2007-09-11T23:23:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [September 12, 2007, 1:52am UTC](https://www.ruby-forum.com/t/rendering-a-partial-through-ajax-and-its-hanging/114376/3 "2007-09-12T01:52:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [September 12, 2007, 1:53am UTC](https://www.ruby-forum.com/t/rendering-a-partial-through-ajax-and-its-hanging/114376/4 "2007-09-12T01:53:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [September 12, 2007, 2:25am UTC](https://www.ruby-forum.com/t/rendering-a-partial-through-ajax-and-its-hanging/114376/5 "2007-09-12T02:25:49Z")

</div>

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.

🙂

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [September 12, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/rendering-a-partial-through-ajax-and-its-hanging/114376/6 "2007-09-12T13:23:15Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [September 12, 2007, 5:17pm UTC](https://www.ruby-forum.com/t/rendering-a-partial-through-ajax-and-its-hanging/114376/7 "2007-09-12T17:17:59Z")

</div>

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
