- if (["GET","DELETE"].includes(method) && !!data)
- {
- // Append query params to URL
- url += "/?" + toQueryString(data);
- }
- xhr.open(method, url, true);
- xhr.setRequestHeader('X-Requested-With', "XMLHttpRequest");
- if (["POST","PUT"].includes(method))
- {
- xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
- xhr.send(JSON.stringify(data));
- }
- else
- xhr.send();
+ if (["GET","DELETE"].includes(method) && !!data)
+ {
+ // Append query params to URL
+ url += "/?" + toQueryString(data);
+ }
+ xhr.open(method, params.serverUrl + url, true);
+ xhr.setRequestHeader('X-Requested-With', "XMLHttpRequest");
+ // Next line to allow cross-domain cookies in dev mode
+ if (params.cors)
+ xhr.withCredentials = true;
+ if (["POST","PUT"].includes(method))
+ {
+ xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
+ xhr.send(JSON.stringify(data));
+ }
+ else
+ xhr.send();