. * */ //Clase encargada de procesar las peticiones ajax require_once 'inc/configuracion.inc'; require_once 'Sql.php'; $ajax = new Ajax(); echo $ajax->procesa(); class Ajax { private function respuesta($exito, $mensaje) { $resp = json_encode(array("success" => $exito, "msj" => $mensaje)); header('Content-Type: application/json', true, 200); return $resp; } public function procesa() { if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $tabla = $_GET['tabla']; $sql = new Sql(SERVIDOR, USUARIO, CLAVE, BASEDATOS); if ($sql->error()) { return $this->respuesta(false, 'Error conectando con la Base de Datos'); } $comando = "update " . mysql_escape_string($tabla) . " set " . mysql_escape_string($_POST['name']) . " = '" . mysql_escape_string($_POST['value']) . "' where id = '" . mysql_escape_string($_POST['pk']). "';"; $sql->ejecuta($comando); $exito = !$sql->error(); $mensaje = $sql->mensajeError(); return $this->respuesta($exito, $mensaje); } } } ?>