skip to Main Content

This question is asked before but it is not working for me. I am using wordpress and I want to provide the location of the url "myfile.php" to my plugin directory but i don’t know is it possible or not. Here is my javascript code:

    xmlhttp.open("GET","myfile.php?q="+str,true);
    xmlhttp.send();
  }
}

Manually it is working fine by providing complete location but is it possible to apply function to get myfile.php by using something like plugin_dir_path( __FILE__ )
Any help is highly appreciated

2

Answers


  1. Chosen as BEST ANSWER

    Thanksfor all of your contrubution. Finally i get the solution by applying php function in it like this:

    xmlhttp.open("GET","<?php
    $ffi= plugin_dir_url( __FILE__ ) . '/myfile.php';
        echo $ffi;?>?q=" +str,true);
        xmlhttp.send();
      }
    

  2. I got the same result like this:

    let pluginPath = "../wp-content/plugins/YOUR_PLUGIN_FOLDER_NAME/";
    
        xmlhttp.open("GET",pluginPath + "myfile.php?q="+str,true);
        xmlhttp.send();
      }
    }
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search