Add message when connection failed when trying to vote.

This commit is contained in:
Ajay Ramachandran
2019-07-20 13:26:55 -04:00
parent b319729da8
commit 4bb6cd0dcf
3 changed files with 17 additions and 2 deletions

View File

@@ -87,7 +87,7 @@ function addSponsorTime(time) {
function submitVote(type, UUID, callback) {
getUserID(function(userID) {
//publish this vote
sendRequestToUser('GET', "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp) {
sendRequestToUser('GET', "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
callback({
successType: 1
@@ -97,6 +97,11 @@ function submitVote(type, UUID, callback) {
callback({
successType: 0
});
} else if (error) {
//error while connect
callback({
successType: -1
});
}
})
})
@@ -180,7 +185,11 @@ function sendRequestToUser(type, address, callback) {
xmlhttp.open(type, serverAddress + address, true);
xmlhttp.onreadystatechange = function () {
callback(xmlhttp);
callback(xmlhttp, false);
};
xmlhttp.onerror = function(ev) {
callback(xmlhttp, true);
};
//submit this request