0

I'm using this script and getting error "Uncaught SyntaxError: missing ) after argument list".

Please help me to get rid of nasty bug, spent lot of time but does not solved.

<script>
function endOfText(){
    <?php 
         $free_text = '<div style="display:block;width:600px;height:340px;background-color:black;">
                    <div style="height:35px;"></div>
                    <div style="height:20px;width:600px;text-align:center;color:white;font-size:20px;">PARTIE SUIVANTE</div>
                    <div style="height:30px;"></div>
                    <div style="display:block;width:300px;height:170px;margin-left:150px;cursor:default;
                    background-image:url("'.$server_free.'thumb/'.$drama_tab['shortcut'].'/'.$drama_tab['shortcut'].$epiNB.'-'.$part_1.'_thumb.jpg");background-size:300px 170px;background-repeat:no-repeat;background-position:center;">
                        <div><a href="javascript:void(0)" onclick="send_epi('.$part_1.')"><img src="'.$http.'images/next_free.png"/></a></div>
                    </div>
                    <div style="height:40px;"></div>
                    <div style="width:600px;text-align:center;color:white;">Ou utilisez les boutons numérotés à droite</div>
                </div>';

    echo '$("#free_video").append("'.$free_text.'");';
   ?>
}

2
  • Can I see the JavaScript code in your HTML? Commented Nov 24, 2017 at 7:40
  • I also try by removing double quotes then also it does not work Commented Nov 24, 2017 at 7:44

1 Answer 1

1

You're printing out echo '$("#free_video").append("'.$free_text.'");';

Which contains 2x " to indicate the string.

While building your $free_text you're also setting in " for the background-image:url("/test/myImg.jpg")

So in the end your error is producted by having something like

$("#free_video").append("background-image:url("/test/myImg.jpg")"); which, of course, won't work.

Solution: Escape your " and/or overthink your usage for ' and "

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

2 Comments

should I use like this echo '$("#free_video").append('.$free_text.');';
No. This would result in an error as well. You need to rework your $free_text or use maybe '$("#free_video").append(\''.$free_text.'\');';

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.