0

Any help will be appreciated. I just want to assign javascript variables inside php code.can you guys sort it.

From the above code.. Need to assign var gtitle into do_shortcode()

<script type="text/javascript">  
    jQuery(document).ready(function($) {
        $(document).on('click', '.map' , function(){
            var gtitle = $(this).data("fpid");
            <?php $data = do_shortcode('+gtitle+'); ?>
        }
    }
</script>   
Logovskii Dmitrii
  • 2,629
  • 4
  • 27
  • 44
  • Your php code only runs when the page is first loaded therefore the click event is ignored. If you view source of your page you might see some rubbish info there. You might also see that the page has produced a JavaScript error. –  Apr 10 '19 at 10:59
  • yes @jeff its showing error now..but what I am trying is $data will be blank onpage load. After onclick event it pass data to shortcode & ajax render it – Sudhir Khadka Apr 10 '19 at 11:06

1 Answers1

1

Might somethink like this:

var gtitle = <?php echo do_shortcode() ?>;