# Ajax + Format.js = :(

**URL:** <https://www.ruby-forum.com/t/ajax-format-js/136397>\
**Category:** Rails\
**Created:** [May 1, 2008, 6:02pm UTC](https://www.ruby-forum.com/t/ajax-format-js/136397 "2008-05-01T18:02:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Grande](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecc23a/32.png) [@Matt\_Grande](https://www.ruby-forum.com/u/Matt_Grande)\
**Post date:** [May 1, 2008, 6:02pm UTC](https://www.ruby-forum.com/t/ajax-format-js/136397/1 "2008-05-01T18:02:50Z")

</div>

Hi all,

I’m calling a method in my controller like this:  
\<%= link\_to\_remote ‘Search’, :url =\> customers\_path + ‘.js’, :with =\>  
“‘name=’ + $(‘name’).value”, :method =\> :get, :update =\> ‘customers’ -  
%\>

And then updating my page like this:  
format.js { render :partial =\> ‘customers/result’, :collection =\>  
@customers }

And my app is telling me that the partial doesn’t exist where it  
should… However, it does. There is definately a partial in app/  
views/customers called \_result.html.erb.

Does anyone know what would be causing this?

---

<div class="post-metadata">

**Author:** ![Matt\_Grande](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecc23a/32.png) [@Matt\_Grande](https://www.ruby-forum.com/u/Matt_Grande)\
**Post date:** [May 1, 2008, 6:57pm UTC](https://www.ruby-forum.com/t/ajax-format-js/136397/2 "2008-05-01T18:57:06Z")

</div>

Heh–I do. Just went through this.

Because you’re calling the partial from the format.js{} block, you’ve  
got to name it \_result.js.erb. Nevermind that it’s actually HTML what’s  
in that file–just call it .js.erb.

(Also–your :url param there looks odd to me–why are you tacking on the  
.js suffix? I would think that by virtue of the fact you’re making an  
XHR request, that rails’ routing magic would get that done for you…)

HTH,

-Roy
