source: trunk/www.guidonia.net/wp/wp-content/plugins/minimax/doc/readme.txt@ 44

Last change on this file since 44 was 44, checked in by luciano, 15 years ago
File size: 3.0 KB
Line 
1***********************************************************************
2What is minimax?
3
4It's a minimal Ajax library. You can read files in the same
5domain but it cannot read from other domains or in a page in a computer
6reading from a file in the same computer, it has to run in a Webserver.
7
8***********************************************************************
9How to use minimax?
10
11First you need to declare minimax.js, and it has to be in the same server
12where the page is. Second, you have to declare the instance of minimax
13
14var minimax = new minimax('url', 'div');
15
16where URL is the URL where we are going to get the contents, and 'div' is
17the id for the div where we are going to put the results. You can set 'div'
18as false so it wouldn't put the text in the page, but even then you can get
19the result.
20
21Second, sometimes we can get data asyncronously, sometimes not. If you have to
22get those data syncronosuly we should create a semaphore. Create a hidden input
23and declare the semaphore for each instance that would use it.
24
25<script>
26 var mx = new minimax('url', 'div');
27</script>
28<input type='hidden' id='semaphore' />
29<script>
30 mx.setSemaphore('semaphore');
31</script>
32
33The input container has to be declared befor we create the semaphore in the
34minimax instance.
35
36Third, if you want a trobbler (something to be show while geting data) you can
37declare it like two states from the same div. You need to know CSS, sorry.
38
39mx.setTrobbler('trobbler_div', 'class_on', 'class_off');
40
41where 'trobbler' is the id of the div, 'class_on' and 'class_off' are the
42classes to switch when start the to read data (on) and stop reading data (off).
43
44<style>
45 div#trobbler {
46 //any css data
47 }
48 div.on#trobbler {
49 visibility : visible;
50 }
51
52 div.off#trobbler {
53 visibility : hidden;
54 }
55</style>
56<input type='hidden' id='semaphore' />
57<div id='trobbler' class='off'>Reading...</div>
58<div id='mx_data'>Loading...</div>
59<script>
60 var mx = new minimax('url', 'mx_data');
61 mx.setTrobbler('trobbler', 'on', 'off');
62</script>
63
64And to get data you can use post('post') or get().
65
66<div id='mx_data'>Loading...</div>
67<script>
68 var mx = new minimax('url', 'mx_data');
69 mx.post('data1=1&amp;data2=2');
70</script>
71
72The contest of <div id='mx_data'> would change, using the result from the url.
73
74If you want to get the data in a variable, insted of write it in the div, you can
75use the variable xhr of the instance.
76
77<script>
78 var mx = new minimax('url', false); //false div, so, don't write
79 mx.get();
80 mx.xhr.onload = function() { //when there is an answer
81 var xml = mx.xhr.responseXML;
82 var text = mx.xhr.responseText;
83 }
84</script>
85
86And if you want to change the div (or span) where the text would go, you can
87use setDiv()
88
89<span id='new-span'>Old-text</span>
90<script>
91 var mx = new minimax('url', false); //false div, so, don't write
92 mx.setDiv('new-span');
93 mx.get();
94</script>
95
96***********************************************************************
97Contact
98
99Ideas? Comments?
100email me: sebaxtian at gawab dot com
101www.sebaxtian.com
Note: See TracBrowser for help on using the repository browser.