javascript - Ajax response with newlines for textarea -
i have problem concerning ajax-request should return string server newlines (\n) fill textarea.
when following javascript, works , shows 2 lines in textarea:
function filltextarea(){ document.getelementbyid('mytextarea').innerhtml = "line1\nline2"; }
but if value server using ajax, \n treated other characters of string , there's 1 line
function filltextarea() { new ajax.request("/myurl/....",{ asynchronous:true, evalscripts:true, onsuccess:function(transport){ document.getelementbyid('mytextarea').innerhtml = transport.responsetext; } }); }
does know how deal newlines in responsetext of ajax request?
don't use .innerhtml = "line1\nline2"
. use .value = "line1\nline2"
instead.
value
form values. not setting html contents here.
Comments
Post a Comment