|
|
|
@ -38931,6 +38931,7 @@ TextSecureServer = function () {
|
|
|
|
|
*/
|
|
|
|
|
function ajax(url, options) {
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
console.log(options.type, url);
|
|
|
|
|
var error = new Error(); // just in case, save stack here.
|
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
|
xhr.open(options.type, url, true /*async*/);
|
|
|
|
@ -38955,12 +38956,15 @@ TextSecureServer = function () {
|
|
|
|
|
try { result = JSON.parse(xhr.responseText + ''); } catch(e) {}
|
|
|
|
|
}
|
|
|
|
|
if ( 0 <= xhr.status && xhr.status < 400) {
|
|
|
|
|
console.log('Success', xhr.status);
|
|
|
|
|
resolve(result, xhr.status);
|
|
|
|
|
} else {
|
|
|
|
|
console.log('Error', xhr.status);
|
|
|
|
|
reject(HTTPError(xhr.status, result, error.stack));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
xhr.onerror = function() {
|
|
|
|
|
console.log('Error', xhr.status);
|
|
|
|
|
reject(HTTPError(xhr.status, null, error.stack));
|
|
|
|
|
};
|
|
|
|
|
xhr.send( options.data || null );
|
|
|
|
|