From 979e5754a5ca7601f573957a69971b4e37bf869a Mon Sep 17 00:00:00 2001 From: ctrlcctrlv Date: Sat, 17 Aug 2013 19:08:54 +0000 Subject: [PATCH] Better error handling --- inc/display.php | 3 +++ js/oekaki.js | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/inc/display.php b/inc/display.php index 0f1bc195..9009be9a 100644 --- a/inc/display.php +++ b/inc/display.php @@ -74,6 +74,9 @@ function error($message, $priority = true, $debug_stuff = false) { if ($config['debug'] && isset($db_error)) { $debug_stuff = array_combine(array('SQLSTATE', 'Error code', 'Error message'), $db_error); } + + // Return the bad request header, necessary for AJAX posts + http_response_code(400); die(Element('page.html', array( 'config' => $config, diff --git a/js/oekaki.js b/js/oekaki.js index c610dd6b..2ff17fc7 100644 --- a/js/oekaki.js +++ b/js/oekaki.js @@ -254,10 +254,9 @@ $("form[name='post']").on("submit", function(e){ processData: false, contentType: false, success: function(data) { - //location.reload(); - console.log(data); + location.reload(); }, - error: function(data) {alert("Something went wrong!"); console.log(data)} + error: function(jq, data) {alert($('h2',jq.responseText).text());} }); }