projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix some translations and error messages
[vchess.git]
/
client
/
src
/
utils
/
ajax.js
diff --git
a/client/src/utils/ajax.js
b/client/src/utils/ajax.js
index
e539f46
..
4573dd8
100644
(file)
--- a/
client/src/utils/ajax.js
+++ b/
client/src/utils/ajax.js
@@
-1,8
+1,8
@@
import params from "../parameters"; //for server URL
import params from "../parameters"; //for server URL
+import { store } from "../store"; //for translations
// 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) {
@@
-25,7
+25,7
@@
export function ajax(url, method, data, success, error) {
if (!success) success = () => {}; //by default, do nothing
if (!error)
error = errmsg => {
if (!success) success = () => {}; //by default, do nothing
if (!error)
error = errmsg => {
- alert(errmsg);
+ alert(
store.state.tr[errmsg] ||
errmsg);
};
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
};
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {