0

I have this URL shown below:

http://www.myServer.net/Posters/CU_Pete'sChristmas_PP.png

Now this is

{
                    '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']
                }

So the problem is that Url contains special character ('), which apparently is not allowing my java script to be proper.

So the script is not executing as intended to do.

This is my javaScrit array generator

$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] . "']
                }";
}

I tried using urlencode, rawurlencode, json_encode, but still the images are not getting downloaded.

<script type="text/javascript">
    $(function(){
        $("#demo").grid({
            'genre' : 'All',
            'items' :
                [
                    <?php echo implode(',', $javascript); ?>
                ]
        });
    });
</script>  

Please help me on this.

1
  • Why did'nt urlencode work? Certainly it does, but maybe you didn't use it correctly. Show that code. Commented Dec 24, 2014 at 9:14

1 Answer 1

1

Replace all the apostrophes in the URLs with %27.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.