From b05394e628d11e1f9026bd2590c38cd2574ed1fb Mon Sep 17 00:00:00 2001 From: jonsowman Date: Sun, 6 Jun 2010 10:21:44 +0100 Subject: [PATCH] Properly handles users asking for non-existent UUIDs --- predict/ajax.php | 11 +++++++---- predict/css/pred.css | 1 - predict/includes/config.inc.php | 9 +++++++++ predict/js/pred.js | 20 +++++++++++++------- 4 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 predict/includes/config.inc.php diff --git a/predict/ajax.php b/predict/ajax.php index 263ad04..ebbce2a 100644 --- a/predict/ajax.php +++ b/predict/ajax.php @@ -1,5 +1,6 @@ diff --git a/predict/js/pred.js b/predict/js/pred.js index 36c457f..b0dde63 100644 --- a/predict/js/pred.js +++ b/predict/js/pred.js @@ -73,13 +73,19 @@ function handlePred(pred_uuid) { function getCSV(pred_uuid) { $.get("ajax.php", { "action":"getCSV", "uuid":pred_uuid }, function(data) { - appendDebug("Got JSON response from server for flight path, parsing..."); - if (parseCSV(data) ) { - appendDebug("Parsing function returned successfully."); - appendDebug("Done, AJAX functions quitting."); - } else { - appendDebug("The parsing function failed."); - } + if(data != null) { + appendDebug("Got JSON response from server for flight path, parsing..."); + if (parseCSV(data) ) { + appendDebug("Parsing function returned successfully."); + appendDebug("Done, AJAX functions quitting."); + } else { + appendDebug("The parsing function failed."); + } + } else { + appendDebug("Server couldn't find a CSV for that UUID"); + throwError("Sorry, we couldn't find the data for that UUID. "+ + "Please run another prediction."); + } }, 'json'); }