0
我有以下字符串作爲我的視圖中的變量輸出到textarea中。這是一個AJAX調用,我可以通過響應看到空間正在通過。但是,在我的textarea中,所有的空白都被忽略。我怎樣才能防止這一點?Rails - 防止textarea忽略空格/特殊字符
"status": "success",
"matches": "1",
"results":
{
"id": "56342",
"call_date": "2011-08-24 00:00:00",
"tracking_number": "12223334444",
"ringto_number": "12223334444",
"direction": "inbound",
"duration": "127",
"file_url": "http://www.logmycalls.com/recordings/somesound.mp3",
"reviewer": "[email protected]",
"scorer": "[email protected]",
"score_grade": "87",
"score_outcome": "pass",
"status": "active"
}
]
這就是它看起來像在textarea的:
[
"status": "success",
"matches": "1",
"results":
{
"id": "56342",
"call_date": "2011-08-24 00:00:00",
"tracking_number": "12223334444",
"ringto_number": "12223334444",
"direction": "inbound",
"duration": "127",
"file_url": "http://www.logmycalls.com/recordings/somesound.mp3",
"reviewer": "[email protected]",
"scorer": "[email protected]",
"score_grade": "87",
"score_outcome": "pass",
"status": "active"
}
]
當你正在尋找的響應可以是瀏覽器所做的文本格式化爲你。 – megas
我的意思是來自螢火蟲AJAX調用的響應...空間在那裏。我添加了css屬性「white-space:pre」,但它隨後顯示爲製表符。 –
只是在開玩笑。 CSS屬性修復了它。這些標籤實際上是字符串的一部分。 :\ –