简体   繁体   English

如何在Wordpress插件的jquery中获取img url和文件url?

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

I am creating a plugin in wordpress. 我在wordpress中创建一个插件。 I am trying to get the img url and file url in jQuery. 我正在尝试在jQuery中获取img网址和文件网址。 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 ?> 假设您使用的是.php文件,则缺少php标签<?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' ?>" >'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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