There is a code:
<form id="myForm" method="post"> <p><textarea id=f13 name="field1"></textarea></p> <p><input type="submit" value="Отправить"></p> </form> <div id="content">111</div> <div id="result">555</div> $(document).ready(function(){ $('#myForm').submit(function(){ var str = $(this).serialize(); var str2 = $('#f13').val(); str2.split('\n'); srt2.forEach(function(item, i, srt2) { $('.result').html(item); }); $.ajax({ type: "POST", url: "test.php", data: str, success: function(html){ $("#content").html(html); } }); return false; }); }); And then there is an error ... It is necessary that an array be created, the separator for which will be a new line, and then the result is output in turn.
str2.split('\n');- Sergey Gornostaevvar str3 = str2.split('\n');replace withstr2.split('\n');- stackanonsrt3.forEach(function(item, i, srt3) { $('#result').html(str3); });constructionsrt3.forEach(function(item, i, srt3) { $('#result').html(str3); });. Why for each element of the array in #result output the entire array? - Sergey Gornostaev