documentation: add JS api docs
[oweals/luci.git] / documentation / jsapi / LuCI.XHR.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <meta charset="utf-8">
5     <title>JSDoc: Class: XHR</title>
6
7     <script src="scripts/prettify/prettify.js"> </script>
8     <script src="scripts/prettify/lang-css.js"> </script>
9     <!--[if lt IE 9]>
10       <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11     <![endif]-->
12     <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13     <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14 </head>
15
16 <body>
17
18 <div id="main">
19
20     <h1 class="page-title">Class: XHR</h1>
21
22     
23
24
25
26
27 <section>
28
29 <header>
30     
31         <h2><span class="attribs"><span class="type-signature"></span></span>
32             <span class="ancestors"><a href="LuCI.html">LuCI</a>.</span>XHR<span class="signature">()</span><span class="type-signature"></span></h2>
33         
34             <div class="class-description"><p>The <code>LuCI.XHR</code> class is a legacy compatibility shim for the
35 functionality formerly provided by <code>xhr.js</code>. It is registered as global
36 <code>window.XHR</code> symbol for compatibility with legacy code.</p>
37 <p>New code should use <a href="LuCI.Request.html"><code>LuCI.Request</code></a> instead to implement HTTP
38 request handling.</p></div>
39         
40     
41 </header>
42
43 <article>
44     <div class="container-overview">
45     
46         
47
48     
49     <h2>Constructor</h2>
50     
51
52     
53     <h4 class="name" id="XHR"><span class="type-signature"></span>new XHR<span class="signature">()</span><span class="type-signature"></span></h4>
54     
55
56     
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 <dl class="details">
73
74     
75
76     
77
78     
79
80     
81
82     
83
84     
85
86     
87
88     
89         <dt class="important tag-deprecated">Deprecated:</dt><dd class="yes-def tag-deprecated"><ul class="dummy"><li>Yes</li></ul></dd>
90     
91
92     
93
94     
95
96     
97
98     
99
100     
101     <dt class="tag-source">Source:</dt>
102     <dd class="tag-source"><ul class="dummy"><li>
103         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line2943">line 2943</a>
104     </li></ul></dd>
105     
106
107     
108
109     
110
111     
112 </dl>
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133     
134     </div>
135
136     
137
138     
139
140     
141
142     
143
144     
145
146     
147
148     
149
150     
151         <h3 class="subsection-title">Methods</h3>
152
153         
154             
155
156     
157
158     
159     <h4 class="name" id="abort"><span class="type-signature"></span>abort<span class="signature">()</span><span class="type-signature"></span></h4>
160     
161
162     
163
164
165
166 <div class="description">
167     <p>Ignored for backwards compatibility.</p>
168 <p>This function does nothing.</p>
169 </div>
170
171
172
173
174
175
176
177
178
179
180
181
182
183 <dl class="details">
184
185     
186
187     
188
189     
190
191     
192
193     
194
195     
196
197     
198
199     
200         <dt class="important tag-deprecated">Deprecated:</dt><dd class="yes-def tag-deprecated"><ul class="dummy"><li>Yes</li></ul></dd>
201     
202
203     
204
205     
206
207     
208
209     
210
211     
212     <dt class="tag-source">Source:</dt>
213     <dd class="tag-source"><ul class="dummy"><li>
214         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line3046">line 3046</a>
215     </li></ul></dd>
216     
217
218     
219
220     
221
222     
223 </dl>
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244         
245             
246
247     
248
249     
250     <h4 class="name" id="busy"><span class="type-signature"></span>busy<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
251     
252
253     
254
255
256
257 <div class="description">
258     <p>Checks the running state of the request.</p>
259 </div>
260
261
262
263
264
265
266
267
268
269
270
271
272
273 <dl class="details">
274
275     
276
277     
278
279     
280
281     
282
283     
284
285     
286
287     
288
289     
290         <dt class="important tag-deprecated">Deprecated:</dt><dd class="yes-def tag-deprecated"><ul class="dummy"><li>Yes</li></ul></dd>
291     
292
293     
294
295     
296
297     
298
299     
300
301     
302     <dt class="tag-source">Source:</dt>
303     <dd class="tag-source"><ul class="dummy"><li>
304         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line3035">line 3035</a>
305     </li></ul></dd>
306     
307
308     
309
310     
311
312     
313 </dl>
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329 <h5>Returns:</h5>
330
331         
332 <div class="param-desc">
333     <p>Returns <code>true</code> if the request is still running or <code>false</code> if it
334 already completed.</p>
335 </div>
336
337
338
339 <dl>
340     <dt>
341         Type
342     </dt>
343     <dd>
344         
345 <span class="param-type">boolean</span>
346
347
348     </dd>
349 </dl>
350
351     
352
353
354
355
356
357         
358             
359
360     
361
362     
363     <h4 class="name" id="cancel"><span class="type-signature"></span>cancel<span class="signature">()</span><span class="type-signature"></span></h4>
364     
365
366     
367
368
369
370 <div class="description">
371     <p>Cancels a running request.</p>
372 <p>This function does not actually cancel the underlying
373 <code>XMLHTTPRequest</code> request but it sets a flag which prevents the
374 invocation of the callback function when the request eventually
375 finishes or timed out.</p>
376 </div>
377
378
379
380
381
382
383
384
385
386
387
388
389
390 <dl class="details">
391
392     
393
394     
395
396     
397
398     
399
400     
401
402     
403
404     
405
406     
407         <dt class="important tag-deprecated">Deprecated:</dt><dd class="yes-def tag-deprecated"><ul class="dummy"><li>Yes</li></ul></dd>
408     
409
410     
411
412     
413
414     
415
416     
417
418     
419     <dt class="tag-source">Source:</dt>
420     <dd class="tag-source"><ul class="dummy"><li>
421         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line3022">line 3022</a>
422     </li></ul></dd>
423     
424
425     
426
427     
428
429     
430 </dl>
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451         
452             
453
454     
455
456     
457     <h4 class="name" id="get"><span class="type-signature"></span>get<span class="signature">(url, data<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>, timeout<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;null>}</span></h4>
458     
459
460     
461
462
463
464 <div class="description">
465     <p>This function is a legacy wrapper around
466 <a href="LuCI.html#get"><code>LuCI.get()</code></a>.</p>
467 </div>
468
469
470
471
472
473
474
475
476
477     <h5>Parameters:</h5>
478     
479
480 <table class="params">
481     <thead>
482     <tr>
483         
484         <th>Name</th>
485         
486
487         <th>Type</th>
488
489         
490         <th>Attributes</th>
491         
492
493         
494
495         <th class="last">Description</th>
496     </tr>
497     </thead>
498
499     <tbody>
500     
501
502         <tr>
503             
504                 <td class="name"><code>url</code></td>
505             
506
507             <td class="type">
508             
509                 
510 <span class="param-type">string</span>
511
512
513             
514             </td>
515
516             
517                 <td class="attributes">
518                 
519
520                 
521
522                 
523                 </td>
524             
525
526             
527
528             <td class="description last"><p>The URL to request</p></td>
529         </tr>
530
531     
532
533         <tr>
534             
535                 <td class="name"><code>data</code></td>
536             
537
538             <td class="type">
539             
540                 
541 <span class="param-type">Object</span>
542
543
544             
545             </td>
546
547             
548                 <td class="attributes">
549                 
550                     &lt;optional><br>
551                 
552
553                 
554
555                 
556                 </td>
557             
558
559             
560
561             <td class="description last"><p>Additional query string data</p></td>
562         </tr>
563
564     
565
566         <tr>
567             
568                 <td class="name"><code>callback</code></td>
569             
570
571             <td class="type">
572             
573                 
574 <span class="param-type"><a href="LuCI.html#.requestCallbackFn">LuCI.requestCallbackFn</a></span>
575
576
577             
578             </td>
579
580             
581                 <td class="attributes">
582                 
583                     &lt;optional><br>
584                 
585
586                 
587
588                 
589                 </td>
590             
591
592             
593
594             <td class="description last"><p>Callback function to invoke on completion</p></td>
595         </tr>
596
597     
598
599         <tr>
600             
601                 <td class="name"><code>timeout</code></td>
602             
603
604             <td class="type">
605             
606                 
607 <span class="param-type">number</span>
608
609
610             
611             </td>
612
613             
614                 <td class="attributes">
615                 
616                     &lt;optional><br>
617                 
618
619                 
620
621                 
622                 </td>
623             
624
625             
626
627             <td class="description last"><p>Request timeout to use</p></td>
628         </tr>
629
630     
631     </tbody>
632 </table>
633
634
635
636
637
638
639 <dl class="details">
640
641     
642
643     
644
645     
646
647     
648
649     
650
651     
652
653     
654
655     
656         <dt class="important tag-deprecated">Deprecated:</dt><dd class="yes-def tag-deprecated"><ul class="dummy"><li>Yes</li></ul></dd>
657     
658
659     
660
661     
662
663     
664
665     
666
667     
668     <dt class="tag-source">Source:</dt>
669     <dd class="tag-source"><ul class="dummy"><li>
670         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line2978">line 2978</a>
671     </li></ul></dd>
672     
673
674     
675
676     
677
678     
679 </dl>
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695 <h5>Returns:</h5>
696
697         
698
699
700 <dl>
701     <dt>
702         Type
703     </dt>
704     <dd>
705         
706 <span class="param-type">Promise.&lt;null></span>
707
708
709     </dd>
710 </dl>
711
712     
713
714
715
716
717
718         
719             
720
721     
722
723     
724     <h4 class="name" id="post"><span class="type-signature"></span>post<span class="signature">(url, data<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>, timeout<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;null>}</span></h4>
725     
726
727     
728
729
730
731 <div class="description">
732     <p>This function is a legacy wrapper around
733 <a href="LuCI.html#post"><code>LuCI.post()</code></a>.</p>
734 </div>
735
736
737
738
739
740
741
742
743
744     <h5>Parameters:</h5>
745     
746
747 <table class="params">
748     <thead>
749     <tr>
750         
751         <th>Name</th>
752         
753
754         <th>Type</th>
755
756         
757         <th>Attributes</th>
758         
759
760         
761
762         <th class="last">Description</th>
763     </tr>
764     </thead>
765
766     <tbody>
767     
768
769         <tr>
770             
771                 <td class="name"><code>url</code></td>
772             
773
774             <td class="type">
775             
776                 
777 <span class="param-type">string</span>
778
779
780             
781             </td>
782
783             
784                 <td class="attributes">
785                 
786
787                 
788
789                 
790                 </td>
791             
792
793             
794
795             <td class="description last"><p>The URL to request</p></td>
796         </tr>
797
798     
799
800         <tr>
801             
802                 <td class="name"><code>data</code></td>
803             
804
805             <td class="type">
806             
807                 
808 <span class="param-type">Object</span>
809
810
811             
812             </td>
813
814             
815                 <td class="attributes">
816                 
817                     &lt;optional><br>
818                 
819
820                 
821
822                 
823                 </td>
824             
825
826             
827
828             <td class="description last"><p>Additional data to append to the request body.</p></td>
829         </tr>
830
831     
832
833         <tr>
834             
835                 <td class="name"><code>callback</code></td>
836             
837
838             <td class="type">
839             
840                 
841 <span class="param-type"><a href="LuCI.html#.requestCallbackFn">LuCI.requestCallbackFn</a></span>
842
843
844             
845             </td>
846
847             
848                 <td class="attributes">
849                 
850                     &lt;optional><br>
851                 
852
853                 
854
855                 
856                 </td>
857             
858
859             
860
861             <td class="description last"><p>Callback function to invoke on completion</p></td>
862         </tr>
863
864     
865
866         <tr>
867             
868                 <td class="name"><code>timeout</code></td>
869             
870
871             <td class="type">
872             
873                 
874 <span class="param-type">number</span>
875
876
877             
878             </td>
879
880             
881                 <td class="attributes">
882                 
883                     &lt;optional><br>
884                 
885
886                 
887
888                 
889                 </td>
890             
891
892             
893
894             <td class="description last"><p>Request timeout to use</p></td>
895         </tr>
896
897     
898     </tbody>
899 </table>
900
901
902
903
904
905
906 <dl class="details">
907
908     
909
910     
911
912     
913
914     
915
916     
917
918     
919
920     
921
922     
923         <dt class="important tag-deprecated">Deprecated:</dt><dd class="yes-def tag-deprecated"><ul class="dummy"><li>Yes</li></ul></dd>
924     
925
926     
927
928     
929
930     
931
932     
933
934     
935     <dt class="tag-source">Source:</dt>
936     <dd class="tag-source"><ul class="dummy"><li>
937         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line3005">line 3005</a>
938     </li></ul></dd>
939     
940
941     
942
943     
944
945     
946 </dl>
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962 <h5>Returns:</h5>
963
964         
965
966
967 <dl>
968     <dt>
969         Type
970     </dt>
971     <dd>
972         
973 <span class="param-type">Promise.&lt;null></span>
974
975
976     </dd>
977 </dl>
978
979     
980
981
982
983
984
985         
986             
987
988     
989
990     
991     <h4 class="name" id="send_form"><span class="type-signature"></span>send_form<span class="signature">()</span><span class="type-signature"></span></h4>
992     
993
994     
995
996
997
998 <div class="description">
999     <p>Existing for backwards compatibility.</p>
1000 <p>This function simply throws an <code>InternalError</code> when invoked.</p>
1001 </div>
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015 <dl class="details">
1016
1017     
1018
1019     
1020
1021     
1022
1023     
1024
1025     
1026
1027     
1028
1029     
1030
1031     
1032         <dt class="important tag-deprecated">Deprecated:</dt><dd class="yes-def tag-deprecated"><ul class="dummy"><li>Yes</li></ul></dd>
1033     
1034
1035     
1036
1037     
1038
1039     
1040
1041     
1042
1043     
1044     <dt class="tag-source">Source:</dt>
1045     <dd class="tag-source"><ul class="dummy"><li>
1046         <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line3061">line 3061</a>
1047     </li></ul></dd>
1048     
1049
1050     
1051
1052     
1053
1054     
1055 </dl>
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069 <h5>Throws:</h5>
1070
1071         
1072
1073 <dl>
1074     <dt>
1075         <div class="param-desc">
1076         <p>Throws an <code>InternalError</code> with the message <code>Not implemented</code>
1077 when invoked.</p>
1078         </div>
1079     </dt>
1080     <dd></dd>
1081     <dt>
1082         <dl>
1083             <dt>
1084                 Type
1085             </dt>
1086             <dd>
1087                 
1088 <span class="param-type">InternalError</span>
1089
1090
1091             </dd>
1092         </dl>
1093     </dt>
1094     <dd></dd>
1095 </dl>
1096
1097
1098     
1099
1100
1101
1102
1103
1104
1105
1106         
1107     
1108
1109     
1110
1111     
1112 </article>
1113
1114 </section>
1115
1116
1117
1118
1119 </div>
1120
1121 <nav>
1122     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="LuCI.html">LuCI</a></li><li><a href="LuCI.Class.html">Class</a></li><li><a href="LuCI.dom.html">dom</a></li><li><a href="LuCI.fs.html">fs</a></li><li><a href="LuCI.Headers.html">Headers</a></li><li><a href="LuCI.Network.html">Network</a></li><li><a href="LuCI.Network.Device.html">Device</a></li><li><a href="LuCI.Network.Hosts.html">Hosts</a></li><li><a href="LuCI.Network.Protocol.html">Protocol</a></li><li><a href="LuCI.Network.WifiDevice.html">WifiDevice</a></li><li><a href="LuCI.Network.WifiNetwork.html">WifiNetwork</a></li><li><a href="LuCI.Poll.html">Poll</a></li><li><a href="LuCI.Request.html">Request</a></li><li><a href="LuCI.Request.poll.html">poll</a></li><li><a href="LuCI.Response.html">Response</a></li><li><a href="LuCI.rpc.html">rpc</a></li><li><a href="LuCI.uci.html">uci</a></li><li><a href="LuCI.view.html">view</a></li><li><a href="LuCI.XHR.html">XHR</a></li></ul>
1123 </nav>
1124
1125 <br class="clear">
1126
1127 <footer>
1128     Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Tue Nov 05 2019 09:33:05 GMT+0100 (Central European Standard Time)
1129 </footer>
1130
1131 <script> prettyPrint(); </script>
1132 <script src="scripts/linenumber.js"> </script>
1133 </body>
1134 </html>