[問題] 用jquery抓json會有unterminated string literal
我用jQuery的Ajax去呼叫一個會產生json格式的php程式
json格式比方說像這樣
[{ chatid:"15",
from_user:"John",
to_user:"我是John",
context:"a",
date_string:"04:45"
},
{ chatid:"16",
from_user:"John",
to_user:"我是John二",
context:"test test",
date_string:"04:45"}]
其中第二項的context裡面 有包含\n字元
導致jquery在抓的時候會有unterminated string literal
我用php的nl2br方式將\n轉成<br />還是會有一樣的問題
請問我要怎麼做才不會有這樣的問題
謝謝回答
--
◢ ˊ_▂▃▄▂_ˋ. ◣ ▅▅▅ ▅▅▅ ι●╮
▍./◤_▂▃▄▂_◥ \'▊ HARUHI ████████ <■┘
▎⊿ ◤◤◥█◥◥█Δ █ ISM ███▃▃███ ¢|\
▏ζ(▏●‵◥′●▊)Ψ ▏ By-gamejye ▂▂▂ ▂▂▂ ⊿Δ
█/|▊ 〃 、 〃▋ |\ ▎ ハ ル ヒ 主 義
◥◥|◣ ‵′ ◢/'◢◢ S‧O‧S 世界を大いに盛り上げるための涼宮ハルヒの団
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.117.39.194
→
02/24 13:00, , 1F
02/24 13:00, 1F
→
02/24 13:00, , 2F
02/24 13:00, 2F
→
02/24 13:00, , 3F
02/24 13:00, 3F
→
02/24 13:38, , 4F
02/24 13:38, 4F
→
02/26 11:42, , 5F
02/26 11:42, 5F