WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here i am sending the ajax response to load_post.php page from my ajax call.I am getting response on load_post.php on load_post.php i have to fire word press query.

I was try this but getting bellow error in response.when i add global $wpdb variable into load_post.php file

Parse error</b>:  syntax error, unexpected T_GLOBAL in <b>/home/skovianc/public_html/test/thefoodieclub.com/wp-content/plugins/woocommerce-booking/load_post.php

ajax code

var time=0;
                            $.post("'. plugins_url().'/woocommerce-booking/load_post.php",
                                 {name: time},

post url file load_post.php code here i want fire wpdb query

<?php session_start();
    echo $name= $_POST["name"];
    file_put_contents("name.txt", $name)

//Query will be some thing like

global $wpdb;
echo $query = $wpdb->prepare( "SELECT start_date FROM {$wpdb->prefix}booking_history");


So how can fire query on ajax post url page load_post.php

share|improve this question
Your error is because you execute load_post.php expecting Wordpress engine be loaded in that but it is obviously not. Please, refer to Wordpress Ajax API any of the several questions about how to use Ajax in Wordpress. – cybmeta Jul 21 '14 at 8:06
is there any way with this what i am looking for – Sanjay Nakate Jul 21 '14 at 8:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.