Ishangarg61 Posted April 18, 2019 Share Posted April 18, 2019 (edited) Hello , i am facing issue in js and php, please help me, i have create one php file and put the <script>ex.ui{"name": "<?php echo for ( esc_attr ( get_option ( 'sclm ) ) ); ?>",}</script> like above script. But i want to put that script in js file. but when i am use that script in js file, then that php code creating problem. so how to get solve that issue. I want that script in js, and that php code will be fetch the value in js. so please help me about that. Thanks Edited April 18, 2019 by Ishangarg61 Quote Link to comment Share on other sites More sharing options...
Barand Posted April 18, 2019 Share Posted April 18, 2019 Store the value from php into a hidden input field <?php $hidden_content = "Hello World"; // CREATE HIDDEN CONTENT ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Example</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript" src="mytest.js"></script> </head> <body> <input type="hidden" id="my-hidden" value="<?=$hidden_content?>"> <!-- STORE HIDDEN CONTENT --> </body> </html> In your js file, get the value from the hidden input $().ready( function() { alert( $("#my-hidden").val()) }) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.