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 (__

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

相关推荐

  • Why Wordpress plugin url ajax doesn&#39;t work?

    I need to send information to the plugin folder via ajax. Wordpress has a function for the link "plugin_dir_url (__

    11小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信