jQuery post textarea wrap hard not show line break -
$('#submit').click(function(){ $.post('/0002.php', $('#foo').serialize(), function(output){ $('#output').html(output); }); }); <form name="foo" id="foo"> <textarea name="t" wrap="hard"></textarea> <span id="submit">click</span> </form> <div id="output"></div>
//php
<?php if(isset($_post['t'])){ echo nl2br($_post['t']); } ?>
i have textarea set wrap hard, not working when utilize jquery post, jquery post doesn't show line breaks.
anyone know how prepare problem?
i believe because 't' going passed @ php if submit form. since doing ajax have pass parameter post request in jquery, not case. in case using serialize whole form removes new lines textarea..open chromebug/firebug , check sending info load post request , give update can help.
so solution workarounds be:
either parse textarea , given width calculate how many chars can fit , set or \r\n after in hidden input/div , send it. char width hard find though , font should fixed width. or actual post have iframe discussed in link sent (http://stackoverflow.com/a/2142815/986160). jquery
No comments:
Post a Comment