Ajax load
Alleen werkt hij dus niet, hij laadt niks in.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
<script>
window.addEvent('domready', function(){
var url = 'pokeren/tafel.php';
// refresh every 4 seconds
var timer = 500;
// periodical and dummy variables for later use
var periodical, dummy;
var log = $('log_res'), persoon = $('gebruikersnaam');
/* our ajax istance */
var ajax = new Ajax(url, {
update: log,
method: 'get',
onComplete: function() {
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
}
});
/* our refresh function: it sets a dummy to prevent
caching of php and add the loader class */
var refresh = (function() {
// dummy to prevent caching of php
dummy = $time() + $random(0, 100) + "=1&kamer=" + $('gebruikersnaam').value;
// we add out fancy spinner
// requests of our php plus dummy as query
ajax.request(dummy);
});
periodical = refresh.periodical(timer, this);
ajax.request($time() + "=1&kamer=" + $('gebruikersnaam')).value;
// start and stop click events
});
</script>
</head>
<body>
<div id="log"><form method="get">
<input type="hidden" value="1" id="gebruikersnaam">
</form>
<div id="log_res"><!-- spanner --></div>
</div>
<span class="clr"><!-- spanner --></span> </div>
</div>
<span class="clr"></span>
</body>
</html>
?>
<script>
window.addEvent('domready', function(){
var url = 'pokeren/tafel.php';
// refresh every 4 seconds
var timer = 500;
// periodical and dummy variables for later use
var periodical, dummy;
var log = $('log_res'), persoon = $('gebruikersnaam');
/* our ajax istance */
var ajax = new Ajax(url, {
update: log,
method: 'get',
onComplete: function() {
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
}
});
/* our refresh function: it sets a dummy to prevent
caching of php and add the loader class */
var refresh = (function() {
// dummy to prevent caching of php
dummy = $time() + $random(0, 100) + "=1&kamer=" + $('gebruikersnaam').value;
// we add out fancy spinner
// requests of our php plus dummy as query
ajax.request(dummy);
});
periodical = refresh.periodical(timer, this);
ajax.request($time() + "=1&kamer=" + $('gebruikersnaam')).value;
// start and stop click events
});
</script>
</head>
<body>
<div id="log"><form method="get">
<input type="hidden" value="1" id="gebruikersnaam">
</form>
<div id="log_res"><!-- spanner --></div>
</div>
<span class="clr"><!-- spanner --></span> </div>
</div>
<span class="clr"></span>
</body>
</html>
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var ajax = new Ajax(url, {
update: log,
method: 'get',
onComplete: function() {
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
}
}).request;
// of
var ajax = new Ajax.Request(url, {
update: log,
method: 'get',
onComplete: function() {
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
}
});
update: log,
method: 'get',
onComplete: function() {
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
}
}).request;
// of
var ajax = new Ajax.Request(url, {
update: log,
method: 'get',
onComplete: function() {
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
}
});
Een van deze syntaxis zijn goed, weet nou nooit welke bij wat hoort ;-) (ene is mootools andere prototype).
maaar weer doet hnij het niet, ik snap niet veel van die firebug igg:pxD
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
[code]
<script>
window.addEvent('domready', function(){
var url = 'http://manaus.gethost.be/pokeren/tafel.php?game=<? echo $_GET['room']; ?>';
// refresh every 4 seconds
var timer = 5;
// periodical and dummy variables for later use
var periodical, dummy;
var log = $('log_res');
var eigen = ${'log_eig'};
var eigurl = 'http://manaus.gethost.be/pokeren/hand.php?game=<? echo $_GET['room']; ?>';
/* our ajax istance */
var ajax = new Ajax(url, {
update: log,
method: 'get',
onComplete: function() {
// when complete, we remove the spinner
log.removeClass('ajax-loading');
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
log.removeClass('ajax-loading');
}
});
var hand = new Ajax(eigurl, {
update: eigen,
method: 'get',
onComplete: function() {
// when complete, we remove the spinner
eigen.removeClass('ajax-loading');
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
eigen.removeClass('ajax-loading');
}
});
/* our refresh function: it sets a dummy to prevent
caching of php and add the loader class */
var refresh = (function() {
// dummy to prevent caching of php
dummy = $time() + $random(0, 100);
// we add out fancy spinner
log.empty().addClass('ajax-loading');
eigen.empty().addClass('ajax-loading');
// requests of our php plus dummy as query
ajax.request(dummy);
hand.request(dummy);
});
// start and stop click events
log.empty().addClass('ajax-loading');
eigen.empty().addClass('ajax-loading');
/* ********************* */
// the periodical starts here, the * 1000 is because milliseconds required
periodical = refresh.periodical(timer * 1000, this);
// this is the first only request, later on will be only the periodical and refresh
// that do the request. If we don't do this way, we have to wait for 4 seconds before
// the first request.
ajax.request($time());
hand.request($time());
});
</script>
?>
[code]
<script>
window.addEvent('domready', function(){
var url = 'http://manaus.gethost.be/pokeren/tafel.php?game=<? echo $_GET['room']; ?>';
// refresh every 4 seconds
var timer = 5;
// periodical and dummy variables for later use
var periodical, dummy;
var log = $('log_res');
var eigen = ${'log_eig'};
var eigurl = 'http://manaus.gethost.be/pokeren/hand.php?game=<? echo $_GET['room']; ?>';
/* our ajax istance */
var ajax = new Ajax(url, {
update: log,
method: 'get',
onComplete: function() {
// when complete, we remove the spinner
log.removeClass('ajax-loading');
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
log.removeClass('ajax-loading');
}
});
var hand = new Ajax(eigurl, {
update: eigen,
method: 'get',
onComplete: function() {
// when complete, we remove the spinner
eigen.removeClass('ajax-loading');
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
eigen.removeClass('ajax-loading');
}
});
/* our refresh function: it sets a dummy to prevent
caching of php and add the loader class */
var refresh = (function() {
// dummy to prevent caching of php
dummy = $time() + $random(0, 100);
// we add out fancy spinner
log.empty().addClass('ajax-loading');
eigen.empty().addClass('ajax-loading');
// requests of our php plus dummy as query
ajax.request(dummy);
hand.request(dummy);
});
// start and stop click events
log.empty().addClass('ajax-loading');
eigen.empty().addClass('ajax-loading');
/* ********************* */
// the periodical starts here, the * 1000 is because milliseconds required
periodical = refresh.periodical(timer * 1000, this);
// this is the first only request, later on will be only the periodical and refresh
// that do the request. If we don't do this way, we have to wait for 4 seconds before
// the first request.
ajax.request($time());
hand.request($time());
});
</script>
?>
Gewijzigd op 01/01/1970 01:00:00 door Manaus
Je voert wéér je Ajax Requests niet uit.
edit: ik gebruik mootools
Gewijzigd op 01/01/1970 01:00:00 door Manaus
Wat geeft firebug aan?