0

I found script type text/php when I using dompdf library, I want to try pass value inside text/php to text/javascript. so I have code like this with type="text/php"

<script type="text/php">
        $myText = 'This is My text';
</script>

and i want to pass value to jquery

<script type=text/javascript>
$('.tess').text($myText);
</script>

and my html like this <div class="tess"></div>, this should return "This is my text" it's possible to pass it?

for reference see this question, dompdf uses script type=text/php and I want to pass it into jquery so I can get the value How can I get the total number of pages in DOMPDF?

AdityaDees
  • 1,022
  • 18
  • 39
  • 2
    `PHP` is a server-side language which is executed before any client-side languages such as `javascript/jQuery` but you can `echo` things into the DOM script or you could use `ajax` to call your `php` file... – NewToJS May 18 '19 at 23:48
  • If that was possible everyone in the world could read your code. Also PHP code is executed at the server and not at the client. You need to install XAMPP for windows or if you are working on ubuntu, install it via apt install php. – TheKeymaster May 18 '19 at 23:50
  • @arundeepchohan return error, sure undifined variable – AdityaDees May 18 '19 at 23:56
  • @NewToJS I don't really understand ajax, that's why I only discuss jquery. maybe you can include an example with ajax? – AdityaDees May 18 '19 at 23:58
  • The only way to understand the use of `AJAX` is from researching it and testing it out for yourself. If I create an example it would mean including comments of each step and usage which will then turn into a tutorial. Sorry. – NewToJS May 19 '19 at 00:07
  • something like this perhaps? https://www.w3schools.com/php/showphp.asp?filename=demo_include3 – Arundeep Chohan May 19 '19 at 00:15

0 Answers0