projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix moves update
[vchess.git]
/
client
/
src
/
utils
/
ajax.js
diff --git
a/client/src/utils/ajax.js
b/client/src/utils/ajax.js
index
5b46078
..
eb30330
100644
(file)
--- a/
client/src/utils/ajax.js
+++ b/
client/src/utils/ajax.js
@@
-2,6
+2,7
@@
import params from "../parameters"; //for server URL
// TODO: replace by fetch API ?
// https://www.sitepoint.com/xmlhttprequest-vs-the-fetch-api-whats-best-for-ajax-in-2019/
// TODO: replace by fetch API ?
// https://www.sitepoint.com/xmlhttprequest-vs-the-fetch-api-whats-best-for-ajax-in-2019/
+// Problem: fetch() does not set req.xhr... see access/ajax() security especially for /whoami
// From JSON (encoded string values!) to "arg1=...&arg2=..."
function toQueryString(data)
// From JSON (encoded string values!) to "arg1=...&arg2=..."
function toQueryString(data)
@@
-37,10
+38,15
@@
export function ajax(url, method, data, success, error)
// Plain text (e.g. for rules retrieval)
return success(xhr.responseText);
}
// Plain text (e.g. for rules retrieval)
return success(xhr.responseText);
}
- if (!res_json.errmsg)
+ if (!res_json.errmsg
&& !res_json.errno
)
success(res_json);
else
success(res_json);
else
- error(res_json.errmsg);
+ {
+ if (!!res_json.errmsg)
+ error(res_json.errmsg);
+ else
+ error(res_json.code + ". errno = " + res_json.errno);
+ }
}
};
}
};