0
我在下面显示这个网址:用PHP/JavaScript的特殊字符处理URL
http://www.myServer.net/Posters/CU_Pete“sChristmas_PP.png
现在,这是
{
'title' : 'Pete\'s Christmas',
'description' : 'A light-hearted holiday tale that even adults will enjoy. A young boy has the worst Christmas ever and soon realises that he’s doomed to repeat the same day over and over again.',
'thumbnail' : ['http://www.myServer.net/Posters/CU_Pete'sChristmas_PP.png'],
'large' : ['http://www.myServer.net/Posters/CU_Pete'sChristmas_PP.png'],
'button_list' :
[
{ 'title':'Demo', 'url' : 'index.php', 'new_window' : true }
],
'tags' : ['Movies']
}
所以问题是,网址中包含特殊字符('),这显然不允许我的Java脚本是正确的。
因此,该脚本未按预期执行。
这是我javaScrit排列生成
$javascript = array();
$count = sizeof($vodAssetArray);
for ($i = 0; $i < $count; $i++)
{
$pieces = explode("/", $vodAssetArray[$i]->genre);
$javascript[] = "
{
'title' : '" . addslashes($vodAssetArray[$i]->title) . "',
'description' : '" . addslashes($vodAssetArray[$i]->description) . "',
'thumbnail' : ['" . ($vodAssetArray[$i]->posterUrl) . "'],
'large' : ['" . ($vodAssetArray[$i]->posterUrl) . "'],
'button_list' :
[
{ 'title':'Demo', 'url' : 'index.php', 'new_window' : true }
],
'tags' : ['" . $pieces[0] . "']
}";
}
我用用urlencode,rawurlencode,json_encode试过,但还是图像都没有得到下载。
<script type="text/javascript">
$(function(){
$("#demo").grid({
'genre' : 'All',
'items' :
[
<?php echo implode(',', $javascript); ?>
]
});
});
</script>
请帮我解决这个问题。
为什么没有urlencode工作?当然可以,但也许你没有正确使用它。显示**那**代码。 –