# AJAX replace\_html error

**URL:** <https://www.ruby-forum.com/t/ajax-replace-html-error/156941>\
**Category:** Rails\
**Created:** [January 5, 2009, 4:24pm UTC](https://www.ruby-forum.com/t/ajax-replace-html-error/156941 "2009-01-05T16:24:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [January 5, 2009, 4:24pm UTC](https://www.ruby-forum.com/t/ajax-replace-html-error/156941/1 "2009-01-05T16:24:37Z")

</div>

# I have a query form that performs a complex SQL query based on form params and then creates a bunch of @user\_x collections for display purposes. However, AJAX is bombing out with what seems to be a simple error. When I submit the form, instead of replacing the desired partial (under the form) it displays:

# try { Element.update("CONTENTS OF PARTIAL SNIPPED);’); throw e }

The partial correctly updates but something small is wrong preventing  
the in-place update.

FORM VIEW  
\<%= javascript\_include\_tag :defaults %\>  
\<% form\_for :query, :url =\> {:action =\> :query\_results} do |f| %\>  
FORM CONTENTS SNIPPED  
\<% form\_remote\_tag :url =\> {:action =\> :query\_results} do %\>  
\<%= submit\_tag “Query” %\>  
\<% end %\>  
\<% end %\>

ACTION  
def query\_results  
@conditions = conditionalize(params[:query])  
@users = User.find(:all, :conditions =\> @conditions)  
respond\_to { |format| format.js }  
end

QUERY\_RESULTS.JS.RJS  
page.replace\_html(“query\_results”, :partial =\> “query\_results”)

---

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [January 5, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/ajax-replace-html-error/156941/2 "2009-01-05T16:27:31Z")

</div>

Forgot an important part!

FORM VIEW (below form)  
\<% if @users %\>

 \<%= render(:partial =\> "query\_results")%\> 
\<% end %\>
