However, when I query the database and try to return a json_encoded object, it just returns empty properties. The PHP code to query the db should be correct as I am using the exact same query to load the page the first time.
Quote
$sql = "SELECT * FROM tbl_p";
$p = ForecastManager::model()->findAllBySql($sql);
if ($p!=null){
print_r(json_encode(array('p'=>$p)));
return;
}
else {
print_r(json_encode("null"));
return;
}
$p = ForecastManager::model()->findAllBySql($sql);
if ($p!=null){
print_r(json_encode(array('p'=>$p)));
return;
}
else {
print_r(json_encode("null"));
return;
}
The javascript used to print out the returned data looks like this:
Quote
$.ajax({
type: 'POST',
url: '<?php echo Yii::app()->createAbsoluteUrl("f/s"); ?>',
data:data,
success:function(data){
alert(data);
},
error: function(data) { // if error occured
alert("Error occured.please try again");
alert(data);
},
dataType:'html'
});
type: 'POST',
url: '<?php echo Yii::app()->createAbsoluteUrl("f/s"); ?>',
data:data,
success:function(data){
alert(data);
},
error: function(data) { // if error occured
alert("Error occured.please try again");
alert(data);
},
dataType:'html'
});
So the javascript alert is then printing out this:
Quote
{"p":[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]}
Any ideas of why it's printing out empty values? How can I access each value returned?

Help












