0

please see my code here :

my HTML code here :

<html>
<head>
<script>
     $(document).ready(function(){
     var myvar = $("#myHeader").html();
     <?php $cattitle = myvar; ?>
     });                     
    </script>
</head>
<body>
<div id="myHeader">Hello World!</div>
</body>
</html>

anyone have idea for that please.

Ravi Varma
  • 145
  • 1
  • 1
  • 10
  • 1
    Not possible. You will have to use AJAX (or a form submission) as PHP runs on the server and JS on the client. I'd suggest you read the duplicate I mentioned to get a better understanding of the differences between the client and server, as well as the page lifecycle. – Rory McCrossan Jan 02 '18 at 09:53
  • 1
    there is a big difference between server-side and client-side programming. You have to use AJAX for this – Alive to die - Anant Jan 02 '18 at 09:53
  • Thanks for your reply, in the same page, how can get jquery variable value to php varibale using ajax? – Ravi Varma Jan 02 '18 at 10:03
  • http://api.jquery.com/jquery.ajax – Rory McCrossan Jan 02 '18 at 10:18
  • Well in theory it is possible to do without ajax by using form submit or get parameters in a url. But you will need to reload your entire page/load another page. – Mark Baijens Aug 10 '18 at 09:09

0 Answers0