Archived
1
0
This commit is contained in:
Jeff Becker 2017-09-30 08:15:55 -04:00
parent dcba36873e
commit cbe6af7349
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

View File

@ -52,20 +52,21 @@ onready(function() {
var ajax = new XMLHttpRequest(); var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function() { ajax.onreadystatechange = function() {
if (ajax.readyState == 4) { if (ajax.readyState == 4) {
if(ajax.status == 201) {
// success
cb(null);
} else if (ajax.status == 200) {
var err = "unknown error"; var err = "unknown error";
var j = null;
try { try {
var j = JSON.parse(ajax.responseText); j = JSON.parse(ajax.responseText);
err = j.error || err; err = j.error || err;
} catch (ex) { } catch (ex) {
err = "error parsing reply: "+ ex; err = "error parsing reply: "+ ex;
} }
cb(err); if(ajax.status == 201) {
// success
cb(null, j);
} else if (ajax.status == 200) {
cb(err, j);
} else { } else {
cb("http "+ajax.status); cb("http "+ajax.status, j);
} }
} else { } else {
elem.innerHTML += "."; elem.innerHTML += ".";
@ -86,9 +87,9 @@ onready(function() {
e.onclick = function() { e.onclick = function() {
e.disabled = true; e.disabled = true;
e.innerHTML = "posting "; e.innerHTML = "posting ";
submitPost(document.forms[0], e, function(err) { submitPost(document.forms[0], e, function(err, j) {
var msg = err || "posted"; var msg = err || "posted";
console.log(msg); console.log(msg, j);
e.innerHTML = msg; e.innerHTML = msg;
setTimeout(function() { setTimeout(function() {
e.disabled = false; e.disabled = false;