简体   繁体   中英

How to put PHP file in JavaScript?

How do I put PHP file in JavaScript. I want to replace awesome font used inside JavaScript with icon that has been created its function to be called.

I want to put this file:

<img class="svgbeloved" src="<?php echo Wo_GetSvg('microphone'); ?>">

to replace the awesome fonts that are in JavaScript:

 function Wa_CleanRecordNodes(){ $(".record-comment-audio").each(function(index, el) { $(el).html('<i class="fa fa-microphone"></i>').attr('data-record', '0'); $('[data-comment-rtime="'+$(el).attr('id')+'"]').text('00:00').addClass('hidden'); });

And I have tried this, but it did not work:

 function Wa_CleanRecordNodes(){ $(".record-comment-audio").each(function(index, el) { $(el).html('<img class="svgbeloved" src="<?php echo Wo_GetSvg('microphone'); ?>">').attr('data-record', '0'); $('[data-comment-rtime="'+$(el).attr('id')+'"]').text('00:00').addClass('hidden'); });

Try with

 let src = <?php echo json_encode(Wo_GetSvg('microphone')); ?>;

And then use that variable. Other ways you can do that is to use axios, cookie or VueJS and pass data into component. Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM