i am using custom plugin to display the values on the wordpress admin side..
My Jquery html file is
<script type='text/javascript'>
jQuery(document).ready(function(){
jQuery("#searchsubmit").click( function(e) {
e.preventDefault();
var data = jQuery("#eventname").val();
var city = jQuery("#city").val();
var date = jQuery("#datepicker").val();
jQuery.ajax({
type:'POST',
url: './admin-ajax.php',
data:{action:'my_action',test:data,test1:city,test2:date},
dataType: 'html',
success: function(response) {
alert(response);
}
});
});
});
</script>
My Plugin File is
add_action('wp_ajax_my_action', 'my_action_callback');
function my_action_callback(){
$name = $_POST['test'];
$city = $_POST['test1'];
$date = $_POST['test2'];
if ($date != '') {
$enddate = date("Y-m-t", strtotime($date));
$dates_sql = " AND start_date <= '$date' ";
}
if ($city != '' && $city != -1)
$destination_sql = "AND venue = '$city'";
if ($name != '' && $name != -1)
$origincity_sql = "AND event_name = '$name'";
$query = " SELECT * FROM <table name> WHERE event_id!='' " . $dates_sql . " " . $destination_sql . " " . $origincity_sql . " ORDER BY start_date DESC ";
$results = $wpdb->get_results($query) or die(mysql_error());
foreach ($results as $row)
{
$message = "<tr><td align='center' id = 'username'>".$row->username."</td><td align='center' id = 'eventname'>".$row->event_name."</td><td align='center' id = 'venue'>". $row->venue."</td><td align='center' id = 'email'>".$row->email."</td><td align='center' id = 'misseddays'>".$row->missed_days."</td><td align='center' id = 'paymentstatus'>".$row->payment_mode."</td><td align='center' id = 'amountpaid'>".$row->amount_paid."</td><td align='center' id = 'amountbalance'>".$row->amount_balance."</td><td align='center' id = 'mailsent'>".$row->mail."</td></tr>";
}
echo $message;
exit();
}
i am not getting the response into the jquery html file despite it is returning -1 as response any changes to be done please help.stuck today on this one.