Skip to content

Commit

Permalink
Added error handling to nominations
Browse files Browse the repository at this point in the history
Closes #30
  • Loading branch information
jstockwin committed Feb 2, 2016
1 parent cbad9c0 commit 9f5795f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion nominate.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,20 @@ function submitFilms(){
numberSelected = 0;
console.log(selectedFilms);
console.log(JSON.stringify(selectedFilms));
var button = document.getElementById("Submit");
button.innerHTML = "Submitting";
var xhr = new XMLHttpRequest();
xhr.open('POST', 'admin/nominationhandler.php');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
console.log(xhr.responseText);
if(xhr.responseText.indexOf("Error")>-1){
button.innerHTML = "ERROR";
}else{
button.innerHTML = "Submitted";
button.style.paddingLeft="5px";
button.style.paddingRight="5px";
}
};
xhr.send('nominations=' + JSON.stringify(selectedFilms) );
}
Expand Down Expand Up @@ -177,7 +186,7 @@ function submitFilms(){
<div style="position:relative; margin: 5% 0;">
<button type="button" id="submit-films" onclick="submitFilms()">Submit</button>
<div id="button-disabler">
<button type="button" class="disabled">Submit</button>
<button type="button" class="disabled" id="Submit">Submit</button>
</div>
</div>
</div>
Expand Down

0 comments on commit 9f5795f

Please sign in to comment.