我提出,发送textarea的内容到PHP页面获取Ajax请求一个小脚本:发送 n使用jQuery阿贾克斯
$.get('./data/pages/admin/actions.php?savepost=1','&post_id=' + $(box).attr('id') + '&text=' + new_text,'text');
NEW_TEXT得到textarea的内容与VAL();
当我从php保存文本时,它没有\ n字符。 Some1可以解决我的问题?谢谢
我提出,发送textarea的内容到PHP页面获取Ajax请求一个小脚本:发送 n使用jQuery阿贾克斯
$.get('./data/pages/admin/actions.php?savepost=1','&post_id=' + $(box).attr('id') + '&text=' + new_text,'text');
NEW_TEXT得到textarea的内容与VAL();
当我从php保存文本时,它没有\ n字符。 Some1可以解决我的问题?谢谢
根本没有对数据进行编码,所以很多事情都会爆炸(百分号,&符号...)。无论是使用上的每个位或encodeURIComponent
(这是比较容易),让jQuery的为你做它:
$.get('./data/pages/admin/actions.php?savepost=1', {
post_id: $(box).attr('id'),
text: new_text
}, 'text');
对数据参数的详细信息,请参阅the docs。
使用encodeURIComponent()
将换行符编码为正确的URL符号。
感谢您的帮助:d – netcelli 2010-02-08 08:49:56
@netcelli:很荣幸,很高兴它帮助。 – 2010-02-08 08:55:30