]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/javascript/backend/libs/jsonopensrfrequest.js
JS side of the OpenSRF request stuff
[working/Evergreen.git] / Open-ILS / src / javascript / backend / libs / jsonopensrfrequest.js
1 try {
2         load_lib('jsOO.js');
3         load_lib('JSON.js');
4 } catch (e) {}
5
6 var __jsonopensrfreqid = 1;
7 var __jsonopensrfreq_hash = {};
8
9 function JSONOpenSRFRequest () {
10         // Cache this for later ...
11         this._hash_id = __jsonopensrfreqid;
12         __jsonopensrfreqid++;
13 }
14
15 JSONOpenSRFRequest.method('open',function (service, method, async) {
16         this._service = service;
17         this._service = method;
18         this._async = (async ? 1 : 0);
19 });
20
21 JSONOpenSRFRequest.method('send', function () {
22
23         __jsonopensrfreq_hash['id' + this._hash_id] = {};
24
25         try {
26                 _OILS_FUNC_jsonopensrfrequest_send(this._hash_id,this._service,this._method,this._async,js2JSON(arguments));
27         } catch (e) {
28                 alert("Sorry, no JSONOpenSRFRequest support");
29         }
30
31         this.responseText = __jsonopensrfreq_hash['id' + this._hash_id].responseText;
32         this.readyState = __jsonopensrfreq_hash['id' + this._hash_id].readyState;
33         this.status = __jsonopensrfreq_hash['id' + this._hash_id].status;
34         this.statusText = __jsonopensrfreq_hash['id' + this._hash_id].statusText;
35         this.responseJSON = JSON2js(this.responseText);
36
37         if (this._async)
38                 this.onreadystatechange();
39 });
40
41