What did you expect ? You've asked controller to update HTML, so controller
generated javascript to do that. You can then execute it on page.
But if you used e.g. remote_function with :update parameter, then Ajax.Request
expect some HTML from server to put into element you've specified.
I think it is (almost always) better to use remote_function without :update
argument, because it gives you more flexibility (not just updating contents
of single element).
render :update is meant be used in the controller as a response to an
AJAX request, it returns pure javascript that will be executed by tha
AJAX code that called the action ... so of course there are no <script>
tags.
Anyway, I'm using this do display the errors in a specific part of my
html, so this is no response to a request.
Everything's a responds to a request. Someone asked if you were doing
a response to an Ajax request. You are apparently injecting JavaScript
when the page first paints.
The following quote is from the manual "Use this in your Ajax response
bodies, either in a <script> tag or as plain JavaScript sent with a
Content-type of "text/javascript"".
So, this is my question, how do I do that? How can I add the script
tags?
You ensure that the strings with <script> appear around it. If it's in
your controller, and if you are not rendering an Ajax-style request,
then use '<script>' + and + '</script>' around the string it returns.
If you are inside a view, go <script><%= render :etc %></script>
Note that there are few reasons to do the former. Yet there might be
many reasons to do the latter - sharing the first-paint code with the
update code, for example.
And note a purist would need the type='text/javascript', the // CDATA
escape things. I don't know what function returns those.