在按钮Javascript中运行Wordpress查询 - WPDB

I want to run a JavaScript function to javascript sending $variables when running a single button, but not how to make the connection of $wpdb from JavaScript.

Any help would be appreciated.

http://code.tutsplus.com/tutorials/writing-custom-queries-in-wordpress--wp-25510

For example:

$wpdb->update(
    'foods',
    array(
        'fruit' => 'apple',  // string
        'year' =>  'value2'  // integer (number)
    ),
    array( 'ID' => 1 ),
    array(
        '%s',   // value1
        '%d'    // value2
    ),
    array( '%d' )
);

When you press a button in the event onClick Query will run in JavaScript but not how to make the connection with the base to give you to run the query.