I am trying to grab data from php
This is my function in php
function getEvent($eventId){
$ret = array();
$ret['events'] = array();
try{
$db = new DBConnection();
$db->getConnection();
$sql = "select a.contact_name,a.userid from `contact` a where a.Id='$eventId'";
$handle = mysql_query($sql);
while ($row = mysql_fetch_object($handle)) {
//$ret['events'][] = $row;
$ret['events'][] = array(
$row->contact_name,
$row->userid
);
}
}catch(Exception $e){
$ret['error'] = $e->getMessage();
}
return $ret;
}
So I did the following at my javascript
var eventId = '2';
var DATA_FEED_URL = "datafetcher.php";
var param = [{ "name": "eventId", value: 9}];
$.post(DATA_FEED_URL + "?method=getEvent",
param,
function(data){
if (data.IsSuccess) {
alert(data.Msg);
//CloseModelWindow(null,true);
}
else {
alert("Error occurs.\r\n" + data.Msg);
}
}
,"json");
The problem is that nothing happens when I run it.
I want to able get the return result of my php, and then set
var contactName = Return Result contact name element under the $ret array from the datafeed
var contactId = Return result contact id element under the $ret array from the datafeed
Is there anything that I am doing wrong?