forked from verdnatura/hedera-web
31 lines
711 B
JavaScript
Executable File
31 lines
711 B
JavaScript
Executable File
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)
|
|
callback (this, this.request.status == 200);
|
|
}
|
|
|
|
,getJson: function ()
|
|
{
|
|
return eval ('('+ this.request.responseText +')');
|
|
}
|
|
});
|