0
1
Fork 0
hedera-web-mindshore/web/js/vn/http-request.js

31 lines
711 B
JavaScript
Raw Normal View History

2015-03-06 23:33:54 +00:00
Vn.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)
2015-03-06 23:33:54 +00:00
callback (this, this.request.status == 200);
}
,getJson: function ()
{
return eval ('('+ this.request.responseText +')');
}
});