0

I have the following function in my plugin

function IsIdInProject($id=null){
    if ($id=="test")
    {
      return true;
    }
     return false;
    }

I need to call this function from my page using jquery, but I do not understand what to put in my url parameter.

This code is located in settings.php page of my plugin (plugins/myplugin/settings.php)

I cannot just call url: mywebsite.com/plugins/myplugins/settings.php, right?

user194076
  • 8,787
  • 23
  • 94
  • 154
  • Possible duplicate of [Using AJAX in a WordPress plugin](http://stackoverflow.com/questions/17855846/using-ajax-in-a-wordpress-plugin) – xphan Oct 21 '15 at 09:02

1 Answers1

-1

try to use action wp_ajax

Demo

add_action( 'wp_ajax_my_action', 'my_action_callback' );
function my_action_callback() {
$var ="no var";
$id=$_REQUEST['id'];
 if ($id=="test")
{
 $var=$id;
}
echo $var;

    wp_die(); // this is required 
}
vrajesh
  • 2,935
  • 3
  • 25
  • 40