diff --git a/extension/qfq/api/delete.php b/extension/qfq/api/delete.php
index 373c1f653f5d07359a61b869796dc7e64019dedc..0da62a021f81e8e9518615df3210e09921eed01c 100644
--- a/extension/qfq/api/delete.php
+++ b/extension/qfq/api/delete.php
@@ -13,6 +13,7 @@ use qfq;
 require_once(__DIR__ . '/../qfq/QuickFormQuery.php');
 require_once(__DIR__ . '/../qfq/store/Store.php');
 require_once(__DIR__ . '/../qfq/Constants.php');
+require_once(__DIR__ . '/../qfq/exceptions/CodeException.php');
 
 
 /**
@@ -47,14 +48,20 @@ require_once(__DIR__ . '/../qfq/Constants.php');
 $answer = array();
 
 $answer[API_REDIRECT] = API_ANSWER_REDIRECT_NO;
-$answer[API_MESSAGE] = 'Something failed';
+$answer[API_MESSAGE] = '';
 $answer[API_STATUS] = API_ANSWER_STATUS_ERROR;
 
+$result[MSG_HEADER] = '';
+$result[MSG_CONTENT] = '';
+
+$modeAnswer = false;
+$flagSuccess = false;
+
 try {
 
     $qfq = new \qfq\QuickFormQuery(['bodytext' => '']);
 
-    $qfq->delete();
+    $flagSuccess = $qfq->delete();
 
     $targetUrl = Store::getVar(SIP_TARGET_URL, STORE_SIP);
     $modeAnswer = Store::getVar(SIP_MODE_ANSWER, STORE_SIP);
@@ -65,21 +72,14 @@ try {
             $answer[API_MESSAGE] = 'delete: success';
             $answer[API_REDIRECT] = API_ANSWER_REDIRECT_CLIENT;
             $answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
-
-            $result[MSG_HEADER] = "Content-Type: application/json";
-            $result[MSG_CONTENT] = json_encode($answer);
-
             break;
 
         case MODE_HTML:
             if ($targetUrl === false || $targetUrl === '') {
-                $result[MSG_CONTENT] = 'Missing target URL. ' . ERROR_MISSING_VALUE;
-            } else {
-                $result[MSG_CONTENT] = '';
+                throw new CodeException('Missing target URL', ERROR_MISSING_VALUE);
             }
 
             $result[MSG_HEADER] = "Location: $targetUrl";
-
             break;
 
         default:
@@ -100,8 +100,6 @@ try {
         $answer[API_FIELD_MESSAGE] = $val;
     }
 
-    $result[MSG_CONTENT] = json_encode($answer);
-
 } catch (qfq\CodeException $e) {
     $answer[API_MESSAGE] = $e->formatMessage();
 } catch (qfq\DbException $e) {
@@ -110,13 +108,27 @@ try {
     $answer[API_MESSAGE] = "Generic Exception: " . $e->getMessage();
 }
 
-// Fallbak. in case an exception has been thrown and $result is not filled.
-if (!isset($result[MSG_HEADER]) && !isset($result[MSG_CONTENT])) {
+// In case $modeAnswer is still missing: try to get it again - maybe the SIP store has been initialized before the exception has been thrown.
+if ($modeAnswer === false) {
+    $modeAnswer = Store::getVar(SIP_MODE_ANSWER, STORE_SIP);
+}
+
+if ($modeAnswer === MODE_JSON) {
+    // JSON
     $result[MSG_HEADER] = "Content-Type: application/json";
     $result[MSG_CONTENT] = json_encode($answer);
+} else {
+    // HTML
+    if (!$flagSuccess) {
+        $result[MSG_CONTENT] = "<p>" . $answer[API_MESSAGE] . "</p>";
+        if (isset($answer[API_FIELD_NAME])) {
+            $result[MSG_CONTENT] .= "<p>" . $answer[API_FIELD_NAME] . " : " . $answer[API_FIELD_MESSAGE] . "</p>";
+        }
+    }
 }
 
-if (isset($result[MSG_HEADER]) && $result[MSG_HEADER] !== '') {
+// Sent header, if given.
+if ($result[MSG_HEADER] !== '') {
     header($result[MSG_HEADER]);
 }
 
diff --git a/extension/qfq/qfq/QuickFormQuery.php b/extension/qfq/qfq/QuickFormQuery.php
index 02fca622e9c8f5a3bc528f09d9ee30d633d4bd90..5c4a99da7eccb0064a38d17ef4a5ece56f286d50 100644
--- a/extension/qfq/qfq/QuickFormQuery.php
+++ b/extension/qfq/qfq/QuickFormQuery.php
@@ -236,7 +236,7 @@ class QuickFormQuery {
             // FORM_DELETE without a form definition: Fake the form wiht only a tableName.
             $table = $this->store->getVar(SIP_TABLE, STORE_SIP);
             if ($table === false) {
-                return '';
+                throw new UserFormException("No 'form' and no 'table' definition found.", ERROR_MISSING_VALUE);
             }
             $sipFound = true;
             $this->formSpec[F_NAME] = '';
@@ -655,11 +655,14 @@ class QuickFormQuery {
     /**
      * Delete a record (tablename and recordid are given) or process a 'delete form'
      *
+     * @return bool
      * @throws CodeException
      */
     public function delete() {
 
         $this->doForm(FORM_DELETE);
+
+        return true;
     }
 
     /**