help on rails 3.0.9 jquery ajax render html

HI    I have a .js.erb file, like:

(1) $('#ajax-content').html(" here to beigin <br/> ") (2) $('#ajax-content').append("   <%= escape_javascript(                render :partial => 'ajaxnewmsg', :locals => { :privatemsg => @privatemsg }       ).html_safe   %> ") (3) $('#ajax-content').append(" yes finished!")

if without (2) , (1),(3) can show the on the web page with firefox. But if there is (2), nothing will show on the ajax-content. I attached the ajax response from firebug at the end. ( anything wrong with that response?)

The question is: what is the best practice to show the complicated html ( render result) in .js.erb template? ( render :partial => 'ajaxnewmsg', :locals => { :privatemsg => @privatemsg } should be perfect legal in rails/ruby )

why it is not working? How could I debug it?

##the response see from firebug $('#ajax-content').html(" yes I am here to beigin <br/> ")

$('#ajax-content').append("<a href=\"/privatemsgs?locale=en\">Back to Inbox<\/a>")

$('#ajax-content').append("   <a href=\"/privatemsgs?locale=en\">Back to Inbox<\/a><br/> \n<h3> \nSend message to :\n<\/h3>\n\n<form accept-charset=\"UTF-8\" action= \"/privatemsgs/createmsg?locale=en\" method=\"post\"><div style= \"margin:0;padding:0;display:inline\"><input name=\"utf8\" type= \"hidden\" value=\"&#x2713;\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"cAmImbh6beNCdYm/OIXo8EFLasELwvaewpw4QvO45TY= \" /><\/div>\n \n\n\n<!--[form:privatemsg]-->\n<b>Name <\/b> <br/> \n &lt;style type=&quot;text/css&quot;&gt; div.auto_complete {\n width: 350px;\n background: #fff;\n }\n div.auto_complete ul {\n border:1px solid #888;\n margin:0;\n padding:0;\n width:100%;\n list-style-type:none;\n }\n div.auto_complete ul li {\n margin:0;\n padding:3px; \n }\n div.auto_complete ul li.selected {\n background-color: #ffb;\n }\n div.auto_complete ul strong.highlight {\n color: #800; \n margin: 0;\n padding:0;\n }\n&lt;/style&gt;\n &lt;input id=&quot;model_auto_completer_hf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd&quot; name=&quot;privatemsg[member_id]&quot; type=&quot;hidden&quot; /&gt; \n &lt;input id=&quot;model_auto_completer_tf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd&quot; name=&quot;member[name]&quot; onchange=&quot;window.setTimeout(function () {this.value = this.model_auto_completer_cache}.bind(this), 200)&quot; onfocus=&quot;if (this.model_auto_completer_cache == undefined) {this.model_auto_completer_cache = this.value}&quot; onkeypress=&quot;return event.keyCode == Event.KEY_RETURN ? false : true&quot; type=&quot;text&quot; /&gt;\n &lt;div class=&quot;auto_complete&quot; id=&quot;model_auto_completer_tf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd_auto_complete&quot;&gt;&lt;/ div&gt;\n &lt;script type=&quot;text/javascript&quot;&gt;\n//&lt;! [CDATA[\nvar model_auto_completer_tf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd_auto_completer = new Ajax.Autocompleter(\'model_auto_completer_tf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd \', \'model_auto_completer_tf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd_auto_complete \', \'/privatemsgs/auto_complete_belongs_to_for_privatemsg_member_name? locale=en\', {afterUpdateElement: function(element, value) { var model_id = /(\\d+)$/.exec(value.id)[1]; $ (&quot;model_auto_completer_hf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd&quot;).value = model_id; element.model_auto_completer_cache = element.value; (Prototype.emptyFunction)(element, value, $ (&quot;model_auto_completer_hf_1b4878a8928a1d6d9bc6d7dc2bd731795525ccbd&quot;), model_id); } , parameters:\'authenticity_token=\' + encodeURIComponent(\'cAmImbh6beNCdYm/OIXo8EFLasELwvaewpw4QvO45TY=\')}) \n//]]&gt;\n&lt;/script&gt;\n\n<br/>\n\n<input id= \"privatemsg_from_member_id\" name=\"privatemsg[from_member_id]\" type= \"hidden\" value=\"349\" />\n\n<b>Subject<\/b><br/>\n<input id= \"privatemsg_subject\" name=\"privatemsg[subject]\" size=\"80\" type= \"text\" />\n\n<br/>\n\n<b>Message<\/b><br/>\n<textarea cols=\"59\" id= \"privatemsg_message\" name=\"privatemsg[message]\" rows=\"15\"><\/

\n<br/>\n\n\n<!--[eoform:privatemsg]-->\n\n <input name=

\"commit\" type=\"submit\" value=\"Send\" />\n<\/form> ")

$('#ajax-content').append(" yes finished!")

thanks.

Sincerely

Min Wang