0
1
Fork 0
hedera-web-mindshore/package/usr/share/hedera-web/js/db/http-request.js

31 lines
699 B
JavaScript
Executable File

Db.HttpRequest = new Class
({
kvPairs: {}
,add: function (map)
{
for (var key in map)
this.kvPairs[key] = map[key];
}
,send: function (file, callback)
{
this.request = new XMLHttpRequest ();
this.request.open ('post', file, true);
this.request.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
this.request.onreadystatechange = this.requestStateChanged.bind (this, callback);
this.request.send (Vn.Url.makeUri (this.kvPairs));
}
,requestStateChanged: function (callback)
{
if (this.request.readyState == 4)
callback (this, this.request.status == 200);
}
,getJson: function ()
{
return eval ('('+ this.request.responseText +')');
}
});