【发布时间】:2014-05-25 23:39:05
【问题描述】:
我正在使用 instagram 的 api 将一些照片输入我的数据库,然后使用 javascript 地图插件 (ammap) 呈现它们。问题是人们在他们的照片描述中发布了各种奇怪的字符和时髦的东西。
在下面的描述中,我得到一个 Uncaught SyntaxError: Unexpected token ILLEGAL
Walking to the Devils Punchbowl Falls in the rain would have been fun if it hadn't been for all the steps. Hardest kilometre I have ever have to trudge! In the end this 130m falls was worth all the effort.
Have a great day.
#all_my_own #au_nz_hotshotz #capturenz #exploring_the_world_21 #hot_shotz #ig_newzealand #inzed #kiwi #nzmustdo #nature_isa #newzealand #nzroadtrip #natureaddict #ourlonelyplanet #roadtrip #travel #thetravelbible #worldbestgram #fpog #arthurspass #purenewzealand
我如何使用数据
- 我从数据库中的文本字段中获取数据
-
然后我在脚本中使用如下
说明:"'border='0' style='padding:15px;'/>
"
现在我注意到,即使在 stackoverflow 中,代码也不会呈现。
这是一个小提琴http://jsfiddle.net/BrRe9/
这是我在 php 中所做的
while ($row = mysql_fetch_assoc($getData)){
$retdata[] = array(
'desc' => $row['desc'],
....
那么这就是我在 javascript 中所做的事情
var dataProvider = {
map: "worldLow",
images:[
<?foreach($retdata as $rr):?>
{
description:"<div style='width:100%;margin:0 auto;text-align:center;'><p><?php echo addslashes($rr['desc']);?></p><div>"
},
<? endforeach;?>
]
};
【问题讨论】:
-
你能在你的描述中显示代码并尝试渲染它吗?
-
看来你需要转义
'
标签: javascript jquery instagram