I am trying to return a record from a custom table. On the client side, I am sending an AJAX request.
<script>
var eventId;
var xmlhttp;
var xmlhttp = new XMLHttpRequest;
function doclick(ddl){
$evtid=-1;
$evtid =ddl.options[ddl.selectedIndex].value;
document.getElementById('hideme').value =
ddl.options[ddl.selectedIndex].value;
document.getElementById('ename').value =
ddl.options[ddl.selectedIndex].text;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = callback;
xmlhttp.open("POST", "http://www.memoriesof.website/id.php", true);
xmlhttp.send();
}
function callback(){
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById('DESCRIPTION').innerHTML = xmlhttp.responseText;
}
}
</script>
$evtid is getting the correct data.
The id.php file:
<?php
$wpdb;
$sql='';
$eid;
$result;
echo print_r($result);
echo 'Howdy: '. print_r($eid);
try {
$sql='select description from mo_events where id = '. '11';
$result = $wpdb.get_results($sql);
echo "Im'''trying...";
} catch (Exception $exc) {
echo $exc->getTraceAsString();
echo 'Caught me.';
} finally {
echo "finally...out: ". print_r($result);
}
echo 'all the way... : '.print_r($result);
This is what shows on the Description textarea: "1Howdy: 1finally...out: 1}
So it looks like I have the client side working. Can someone help me figure out how to get the data back to the client? Thanks...Dan';