简体   繁体   中英

How to get img url and file url in jquery in wordpress plugin?

I am creating a plugin in wordpress. I am trying to get the img url and file url in jQuery. Code below. What did I do wrong?

 $('.result_tag') .append('<img src="plugin_dir_url( __FILE__ ).'remove_sign.png'" >'); $.post("plugin_dir_url( __FILE__ ).'delete.inc.php'", { tag : text,/ }, function(data){ $("#result_tag").html(data); }); 

supposing you are working in a .php file, you are missing the php tags <?php ?>

$('.result_tag')
  .append('<img src="<?php echo plugin_dir_url( __FILE__ ).'remove_sign.png' ?>" >');

$.post("<?php echo plugin_dir_url( __FILE__ ).'delete.inc.php' ?>", {
    tag : text,/
  },
  function(data){
      $("#result_tag").html(data); 
});

just change

'<img src="plugin_dir_url( __FILE__ ).'remove_sign.png'" >'

to

'<img src="<?php echo plugin_dir_url( __FILE__ ).'remove_sign.png' ?>" >'

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