我提出,發送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