theITvideos Posted November 15, 2010 Share Posted November 15, 2010 Hi there, I am working on a php web form. I have a variable named $isFruit having value of 1 When I do a: print_r($isFruit) It gives me value as 1, which is good. Now I need to pass this php variable into a jquery function: $('document').ready(function() { //I need to get the value of $isFruit variable here } How can pass the php variable into this function. Kindly reply. All comments and feedbacks are always welcomed. Thank you! Link to comment https://forums.phpfreaks.com/topic/218685-how-to-pass-simple-php-variable-to-jquery/ Share on other sites More sharing options...
TrueColors Posted November 15, 2010 Share Posted November 15, 2010 <?php $isFruit = "some var"; ?> <script type="text/javascript"> $(function() { alert("<?php echo $isFruit; ?>"); } </script> Should do the trick. Link to comment https://forums.phpfreaks.com/topic/218685-how-to-pass-simple-php-variable-to-jquery/#findComment-1134249 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.