com web/php: Modified the response handling from the API on master to return a useful error message in case of failure for the voting feature.:
js/usernotes.js manual/vote-note.php
| From: | Sherif Ramadan | Date: | Wed, 12 Dec 2012 17:49:10 +0000 |
| Subject: | com web/php: Modified the response handling from the API on master to return a useful error message in case of failure for the voting feature.: js/usernotes.js manual/vote-note.php |
||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-15063@lists.php.net to get a copy of this message | ||
Commit: 8fb7c3de1990202a6d677882a44ac247d3b32f8d
Author: Sherif Ramadan <googleguy@php.net> Wed, 12 Dec 2012 12:49:10 -0500
Parents: 61152c6ae9402a547f216b924f121491bfbd934b
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=8fb7c3de1990202a6d677882a44ac247d3b32f8d
Log:
Modified the response handling from the API on master to return a useful error message in case of
failure for the voting feature.
Changed paths:
M js/usernotes.js
M manual/vote-note.php
Diff:
diff --git a/js/usernotes.js b/js/usernotes.js
index d1d03dd..83804ea 100644
--- a/js/usernotes.js
+++ b/js/usernotes.js
@@ -23,8 +23,8 @@ $(document).ready(function() {
}
else {
var responsedata = "Error :(";
- if (data.message != null) {
- responsedata = data.message;
+ if (data.msg != null) {
+ responsedata = data.msg;
}
$("#V"+id).html("<div style=\"float: left; width: 16px;
height: 16px; background-image: url(/images/notes-features.png); background-position:-32px 0px;
margin-right: 8px; overflow: hidden;\" border=\"0\" alt=\"fail\"
title=\"" + responsedata + "\"></div>");
}
diff --git a/manual/vote-note.php b/manual/vote-note.php
index 74ec804..cb0a82e 100644
--- a/manual/vote-note.php
+++ b/manual/vote-note.php
@@ -36,16 +36,19 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
);
if (($r = posttohost($master_url, $data)) === null || strpos($r,"failed to open socket
to") !== false) {
$response["success"] = false;
- $response["msg"] = "Invalid request.";
+ $response["msg"] = "Could not process your request at this time. Please try
again later...";
}
else {
$r = json_decode($r);
if (json_last_error() == JSON_ERROR_NONE && isset($r->status) &&
$r->status && isset($r->votes)) {
$response["success"] = true;
$response["update"] = (int)$r->votes;
+ } elseif (json_last_error() == JSON_ERROR_NONE && isset($r-status) &&
isset($r->message) && $r->status == false) {
+ $response["success"] = false;
+ $response["msg"] = $r->message;
} else {
$response["success"] = false;
- $response["msg"] = "Response unrecognized.";
+ $response["msg"] = "The server did not respond properly. Please try again
later...";
}
}
}