public function update_key() { $this->header('Content-Type: application/javascript', 200); $this->layout = false; $this->key = Pki::update($_GET['id'], $_POST['pki']); if ($this->key->save()) { echo "facebox.close();window.location.href=window.location.href;"; } else { $this->key->id = $_GET['id']; $return = escape_javascript($this->render_partial('user/edit_key.php')); echo "\$('pki').replace('{$return}');"; } $this->has_rendered = true; }