<?
/** -------------------------------------------------------------------------------------*
* Version: 1.0 *
* License: http://phpwebpad.hafij.com @copyright from 2010 *
* ---------------------------------------------------------------------------------------*
* DEVELOPED BY *
* Mohammad Hafijur Rahman (Badal) *
* hide@address.com, hide@address.com *
* ------------------------------------------------------------------------------------ **/
/**
* This class is used in ajaxaction by
* the controller to be used this object
* by javascript.
*/
class JSONResponse {
private $var = array();
/**
* Set JSON variable.
* @param string $name
* @param string $value
*/
public function setVar($name, $value) {
$name = Database::escapeString($name);
$value = Database::escapeString($value);
$this->var[$name] = $value;
}
/**
* Return JSON string.
* @return string
*/
public function getResponse() {
$res_string = "{";
foreach($this->var as $key => $val) {
$res_string = $res_string . '"'. $key . '":"'. $val .'",';
}
$res_string = rtrim($res_string, ",") . "}";
return $res_string;
}
}
?>