hey guys, quick question, I have a function running in php and I am trying to pass json encoded information to the original page. It works fine except when I am doing checks within a function, then for some reason the information is not passed back. Was wondering if anyone had an idea why.
This is my success function
Code: Select all
success: function(response, status){
alert(response.error);
}
this is an example of executing the add command, only the 3 data array values message,time, and name outside the insert message function are defined and successfully passed back. The error messages I try to pass back within the insertMessage function when it is run are not for some reason. For example, within the function, $data['error']='test';
Code: Select all
case 'add':
$time = time();
insertMessage($_POST['name'], $_POST['message'], $_POST['topic_id']);
$data['name'] = $_POST['name'];
$data['message'] = $_POST['message'];
$data['time'] = $time;
break;
require_once('JSON.php');
$json = new Services_JSON();
$out = $json->encode($data);
print $out;