Why Wordpress plugin url ajax doesn't work?
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();
Topic plugins-url wp-filesystem ajax urls plugins Wordpress
Category Web