I need to send information to the plugin folder via ajax. Wordpress has a function for the link "plugin_dir_url (__ FILE__)" which works properly but if I put it in ajax it doesn't work.
Function: plugin_dir_url (__ FILE__) = http: // localhost / aa / wp-content / plugins / pluginfolder /
This works normally:
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
}
};
xmlhttp.open("GET", "http://localhost/aa/wp-content/plugins/pluginfolder/wp-getinfo.php?"&SENDINFO=sendinfo, true);
xmlhttp.send();
This does not work (php inside url):
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
}
};
xmlhttp.open("GET", ""+<?php echo plugin_dir_url(__FILE__) .?>+" wp-save.php?"&SENDINFO=sendinfo, true);
xmlhttp.send();
This does not work (php url as variable):
var urlwp = <?php echo plugin_dir_url(__FILE__) . 'wp-getinfo.php?' ?>;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
}
};
xmlhttp.open("GET", ""+urlwp+"&SENDINFO=sendinfo, true);
xmlhttp.send();
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742401664a4437034.html
评论列表(0条)