Reputation: 1337
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);
});
Upvotes: 1
Views: 1005
Reputation: 7823
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' ?>" >'
Upvotes: 2