0

I try since a view hours a working script but get errors so far... a jquery script which should get a post meta from php

working one:

descrip= "<\?php $my_meta =get_post_meta(3713, 'HourEnd',true );echo $my_meta; \?>";
 console.log(descrip);

not working:

postid=3713;

descrip= "<\?php $my_meta =get_post_meta("+postid+", 'HourEnd',true );echo $my_meta; \?>";
 console.log(descrip);

dont know how to send a variable from jquery to a php insert thanks thomas

  • I presume that the escaped question marks are not part of your real code. What is your JavaScript code? Please post it. –  Feb 21 '21 at 09:07
  • if you want to use JS variables in PHP, you need to make an ajax request, passing that value to PHP. The above doesn't work because PHP is a server side language that gets executed on the server before the contents gets sent to the client (where your JS gets executed). – M. Eriksson Feb 21 '21 at 10:04
  • 2
    Does this answer your question? [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) - When reading this, remember that PHP is server side and JS client side. – M. Eriksson Feb 21 '21 at 10:06
  • ok thanks understand that ;-) – thomas4711 Feb 21 '21 at 11:44

0 Answers0