Kalender met AJAX response en MySQL database

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Brecht S

Brecht S

04/07/2014 15:19:46
Quote Anchor link
Ik heb volgend script gevonden op het net en al voor een groot stuk aangepast naar mijn wensen maar ik zit nog met een aantal problemen hier en daar waar iemand van jullie mij zeker verder zal kunnen mee helpen.
Wat ik hier wil bereiken is een kalender weergeven met keuze van maand, dag, enz... zoals het er staat. Klik je op een datum dan gaat die blauw kleuren en automatisch worden opgeslagen in de database. Klik je terug op die datum dan gaat die terug uit de database verwijderd worden.

1. Het probleem echter is wel dat de tekst er boven verschijnt dat het in de database is opgeslagen of verwijderd maar die zou eronder moeten komen omdat daar de mogelijke uren van de geselecteerde dag zouden moeten weergegeven worden afhankelijk van hetgeen in de database te vinden is onder die dag.

2. Zijn er voor die dag al 50 boekingen dan moet het vakje ipv blauw rood worden en mag er indien mogelijk niet meer op geklikt kunnen worden of moet er een tekst verschijnen dat die dag geen boekingen worden aanvaard.


Hieronder een post van het script tot nu toe:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>

<style>
.calendar_date                    { font-family : Verdana, Arial, Helvetica, sans-serif; font-size : 14px; color : #222222; }
a.calendar_date                    { color: #0000aa; text-decoration: none; }
a.calendar_date:hover            { color: #000080; text-decoration: underline; }

.calendar_navigation            { font-family : Verdana, Arial, Helvetica, sans-serif; font-size : 14px; color : #222222; }
a.calendar_navigation            { color: #0000aa; text-decoration: none; }
a.calendar_navigation:hover        { color: #000080; text-decoration: underline; }

.calendar_day                    { font-family : Verdana, Arial, Helvetica, sans-serif; font-size : 11px; color : #222222; }
a.calendar_day                    { color: #0000aa; text-decoration: none; }
a.calendar_day:hover            { color: #000080; text-decoration: underline; }

.calendar_date_number            { font-family : Verdana, Arial, Helvetica, sans-serif; font-size : 10px; color : #222222; }
a.calendar_date_number            { color: #0000aa; text-decoration: none; }
a.calendar_date_number:hover    { color: #000080; text-decoration: underline; }

.calendar_date_small                    { font-family : Verdana, Arial, Helvetica, sans-serif; font-size : 12px; color : #222222; }
a.calendar_date_small                    { color: #0000aa; text-decoration: none; }
a.calendar_date_small:hover            { color: #000080; text-decoration: underline; }

.calendar_navigation_small            { font-family : Verdana, Arial, Helvetica, sans-serif; font-size : 12px; color : #222222; }
a.calendar_navigation_small            { color: #0000aa; text-decoration: none; }
a.calendar_navigation_small:hover        { color: #000080; text-decoration: underline; }

.calendar_day_small                    { font-family : Verdana, Arial, Helvetica, sans-serif; font-size : 10px; color : #222222; }
a.calendar_day_small                    { color: #0000aa; text-decoration: none; }
a.calendar_day_small:hover            { color: #000080; text-decoration: underline; }

.calendar_date_number_small            { font-family : Verdana, Arial, Helvetica, sans-serif; font-size : 9px; color : #222222; }
a.calendar_date_number_small            { color: #0000aa; text-decoration: none; }
a.calendar_date_number_small:hover    { color: #000080; text-decoration: underline; }

table.rounded td         { -moz-border-radius: 10px 10px 10px 10px; }
table.rounded5 td         { -moz-border-radius: 5px 5px 5px 5px; }
table.notrounded td         { -moz-border-radius: 0px 0px 0px 0px; }

.text                    { font-family : Verdana, Arial, Helvetica, sans-serif; font-size : 13px; color : #222222; }
a.text                    { color: #0000aa; text-decoration: none; }
a.text:hover            { color: #222222; text-decoration: underline; }

</style>


</head>
<body>
<?PHP

$global
= "";
$field = "";
$input = "";
$text = "";

$global['dbhost'] = "localhost";
$global['dbname'] = "***************";
$global['dbuser'] = "***************";
$global['dbpass'] = "***************";

$global['timezone'] = "";
$global['envself'] = $_SERVER['PHP_SELF'];

ini_set('error_reporting', E_ALL | E_STRICT);
ini_set('display_errors', 'On');
#ini_set('log_errors', 'On');
#ini_set('error_log', 'errors.log');




if (isset($_GET['ajax'])) {
    $input['ajax'] = mysql_escape_string(htmlentities(strip_tags($_GET['ajax'])));
}
else {
    $input['ajax'] = "";
}

if ($input['ajax']=="1") {

    if (isset($global['dbname'])) {
    }
else {
        if ($global['dbname']=="") {
            exit;
        }
    }


    $field['ajax_calendar_username'] = mysql_escape_string(htmlentities(strip_tags($_GET['u'])));
    $field['ajax_calendar_date'] = mysql_escape_string(htmlentities(strip_tags($_GET['d'])));

    if ($field['ajax_calendar_date']!="") {

        $field['ajax_calendar_status'] = mysql_escape_string(htmlentities(strip_tags($_GET['s'])));

        if ($field['ajax_calendar_status']=="1") {
            //$query = "INSERT INTO oc_calendar (start_date, end_date, username) VALUES ('$field[ajax_calendar_date] 00:01', '$field[ajax_calendar_date] 23:59', '$field[ajax_calendar_username]');";
            $response = "Gekozen voor ". $field['ajax_calendar_date'];
            $response .= "<br><br>Kies hieronder de datum";
        }
else {
            //$query = "DELETE FROM oc_calendar WHERE start_date LIKE '$field[ajax_calendar_date]%' AND username = '$field[ajax_calendar_username]';";
            $response = "Terug uit database halen => Verwijderen!";
        }


    }


    print "<span class=\"text\">".$response."</span>";
    exit;

}



function
calendar($year = "", $month = "", $username = "0", $small = "0", $calendar_owner = "0") {

global $global;
global $field;
global $input;
global $text;

if (isset($global['timezone'])) {
}
else {
    $global['timezone'] = "";
}

if ($global['timezone']=="") {
    $global['timezone'] = "Europe/Brussels";
}


if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set($global['timezone']);
}


if ("$month"=="") {
    $month = date("n");
}

if ("$year"=="") {
    $year = date("Y");
}


if (isset($_GET['m'])) {
    $month = mysql_escape_string(htmlentities(strip_tags($_GET['m'])));
}

if (isset($_GET['y'])) {
    $year = mysql_escape_string(htmlentities(strip_tags($_GET['y'])));
}




$last_year = $year;
$last_month = $month;
$last_month--;
if ("$last_month"=="0") {
$last_year--;
$last_month = "12";
}


$next_year = $year;
$next_month = $month;
$next_month++;
if ("$next_month"=="13") {
$next_year++;
$next_month = "1";
}


$timestamp = mktime (0, 0, 0, $month, 1, $year);

$time = date("H:i:s");

$monthname = date("F", $timestamp);

if ($calendar_owner=="1") {
    print<<<END
<script type="text/javascript" src="functions.js"></script>
<script type="text/javascript" src="ajax_queue.js"></script>
<script type="text/javascript">

var calendar_status = new Array();

function calendar_date(id,status,username,default_color) {

    var dateid = document.getElementById(id);

    if (calendar_status[id]) {
    } else {
        calendar_status[id] = status;
    }
    if (calendar_status[id]=="0") {
        calendar_status[id] = "1";
    } else {
        calendar_status[id] = "0";
    }

    SimpleAJAXCall('calendar.php?ajax=1&u=' + username + '&d=' + id + '&s=' + calendar_status[id],SimpleAJAXCallback, '', 'response');

    if (calendar_status[id]=="0") {
        dateid.style.background = "#" + default_color;
    } else {
        dateid.style.background = "#0067C9";
    }
}

</script>
END
;
}


if ("$small"=="1") {
    $width = "18";
    $small = "_small";
}
else {
    $width = "22";
    $small = "";
}


#<table cellpadding=1 cellspacing=0 border=0 class="rounded">
#<tr>
#    <td bgcolor="#000080">
#<table cellpadding=5 cellspacing=0 border=0 class="rounded">
#<tr>
#    <td bgcolor="#e7e7e7">


$output = <<<END
    <table border="0" cellpadding="3" cellspacing="2" class="rounded5">
        <tr>
        <td width=$width>
END
;
if ($small=="") {
$output .= <<<END
        <span class="calendar_navigation$small"><a href="$global[envself]?u=$username&y=$last_year&m=$last_month" class="calendar_navigation$small"><b>&lt;&lt;</b></a></span>
END
;
}

$output .= <<<END
        </td>

        <td colspan="5" align="center">
            <span class="calendar_date$small"><b>$monthname $year</span>
        </td>
        <td width=$width align=right>
END
;
if ($small=="") {
$output .= <<<END
        <span class="calendar_navigation$small"><a href="$global[envself]?u=$username&y=$next_year&m=$next_month" class="calendar_navigation$small"><b>&gt;&gt;</b></a></span>
END
;
}

$output .= <<<END
        </td>
        </tr>
        <tr>
        <td width=$width align=center bgcolor="#d7d7d7">
            <span class="calendar_day$small"><b>Zo</b></span>
        </td>
        <td width=$width align=center bgcolor="#d7d7d7">
            <span class="calendar_day$small"><b>Ma</b></span>
        </td>
        <td width=$width align=center bgcolor="#d7d7d7">
            <span class="calendar_day$small"><b>Di</b></span>
        </td>
        <td width=$width align=center bgcolor="#d7d7d7">
            <span class="calendar_day$small"><b>Wo</b></span>
        </td>
        <td width=$width align=center bgcolor="#d7d7d7">
            <span class="calendar_day$small"><b>Do</b></span>
        </td>
        <td width=$width align=center bgcolor="#d7d7d7">
            <span class="calendar_day$small"><b>Vr</b></span>
        </td>
        <td width=$width align=center bgcolor="#d7d7d7">
            <span class="calendar_day$small"><b>Za</b></span>
        </td>
        </tr>
    </table>
    <table border="0" cellpadding="3" cellspacing="2" class="rounded5">
END
;

            $monthstart = date("w", $timestamp);
            //if ($monthstart == 0){
                //$monthstart = 7;
            //}

            $lastday = date("d", mktime (0, 0, 0, $month + 1, 0, $year));
            $startdate = -$monthstart;

            //Figure out how many rows we need.
            $numrows = ceil (((date("t",mktime (0, 0, 0, $month + 1, 0, $year)) + $monthstart) / 7));

            //Let's make an appropriate number of rows...


            for ($k = 1; $k <= $numrows; $k++){
                $output .= "<tr>";
                //Use 7 columns (for 7 days)...
                for ($i = 0; $i < 7; $i++){
                    $startdate++;
                    if (($startdate <= 0) || ($startdate > $lastday)){
                        //If we have a blank day in the calendar.
                        $output .= "<td><span class=\"calendar_date_number$small\">&nbsp;</span></td>";
                    }
else {

                        if (strlen($month) == "1") {
                            $fmonth = "0".$month;
                        }
else {
                            $fmonth = $month;
                        }

                        if (strlen($startdate) == "1") {
                            $fstartdate = "0".$startdate;
                        }
else {
                            $fstartdate = $startdate;
                        }



                        $lookup_date = "$year"."-"."$fmonth"."-"."$fstartdate";
                        $date_status = "";

                        if (($username!="") && ($global['dbuser']!="")) {
                            $date_status = date_status($lookup_date, $username);
                        }


                        $status_color = "0067C9";
                        $js_status = "1";

                        if ($startdate == date("j") && $month == date("n") && $year == date("Y")){

                            if ($date_status!="1") {
                                $status_color = "CAD7F9";
                                $js_status = "0";
                            }


                            $output .= "<td id=\"$year"."-"."$fmonth"."-"."$fstartdate\" width=$width valign=top align=center onclick=\"calendar_date('$year"."-"."$fmonth"."-"."$fstartdate','$js_status','$username','CAD7F9');\" bgcolor=\"#$status_color\">

                            <table width=\"100%\" cellpadding=2 cellspacing=0 border=0><tr><td align=center>

                            <span class=\"calendar_date_number$small\">$startdate</span>

                            </td></tr></table></td>"
;

                        }
else {

                            if ($date_status!="1") {
                                $status_color = "e7e7e7";
                                $js_status = "0";
                            }


                            $output .= "<td id=\"$year"."-"."$fmonth"."-"."$fstartdate\" width=$width valign=top align=center onclick=\"calendar_date('$year"."-"."$fmonth"."-"."$fstartdate','$js_status','$username','e7e7e7');\" bgcolor=\"#$status_color\">

                            <table width=\"100%\" cellpadding=2 cellspacing=0 border=0><tr><td align=center>

                            <span class=\"calendar_date_number$small\">$startdate</span>

                            </td></tr></table></td>"
;
                        }
                    }
                }

                $output .= "</tr>";
            }

    $output .= "</table>"; # </td></tr></table></td></tr></table>

    if ("$calendar_owner"=="1") {

        $output = "<div id=\"response\"></div>".$output;

    }


return $output;

}

function
database($querydb) {

global $global;
global $field;

if (isset($global['queries'])) {
    $global['queries']++;
}
else {
    $global['queries'] = "1";
}

$field['queries'] = $global['queries'];
if (isset($global['query_log'])) {
    $global['query_log'] .= "\n<br>$querydb";
}
else {
    $global['query_log'] = "$querydb";
}


mysql_connect($global['dbhost'], $global['dbuser'], $global['dbpass']) or return_error("Unable to connect to host $global[dbhost]");
mysql_select_db($global['dbname']) or return_error("Unable to select database $global[dbname]");
$global['dbresult'] = mysql_query($querydb) or return_error("Query Error: $querydb");

if ((substr($querydb,0,6)!="INSERT") && (substr($querydb,0,6)!="UPDATE") && (substr($querydb,0,6)!="DELETE")) {

    $global['dbnumber'] = mysql_numrows($global['dbresult']);

}


return;

}

function
return_error($error) {
print $error;
exit;
}

function
date_status($date, $username) {

global $global;
global $field;
global $input;
global $text;

$status = "0";

if ($username!="") {

    $query = "SELECT id, start_date, end_date FROM oc_calendar WHERE username = '$username' AND (date_format(start_date,'%Y-%m-%d') <= date_format('$date','%Y-%m-%d') AND date_format(end_date,'%Y-%m-%d') >= date_format('$date','%Y-%m-%d'))";

    database($query);

    for ($i = 0; $i < $global['dbnumber']; $i++) {

        $status = "1";

        $event_id = mysql_result($global['dbresult'],$i,"id");
        $event_start_date = mysql_result($global['dbresult'],$i,"start_date");
        $event_end_date = mysql_result($global['dbresult'],$i,"end_date");

    }
}


return $status;

}



print calendar("", "", "testuser", 0, 1);








?>

</body>
</html>



En de SQL code:

CREATE TABLE `oc_calendar` (
`id` mediumint(9) NOT NULL auto_increment,
`start_date` datetime NOT NULL,
`end_date` datetime NOT NULL,
`username` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) AUTO_INCREMENT=1 ;
 
PHP hulp

PHP hulp

21/11/2024 13:51:59
 
Php knipper

php knipper

04/07/2014 17:34:48
Quote Anchor link
sorry ik zie geen ajax
 
Brecht S

Brecht S

04/07/2014 18:48:00
Quote Anchor link
Lijn 75 tot 111 en lijn 194
 
Obelix Idefix

Obelix Idefix

04/07/2014 19:55:48
Quote Anchor link
Op http://www.pfz.nl/forum/topic/10756-kalender-met-ajax-response-en-mysql-database/ staat dezelfde vraag.
Niet erg dat je niet op 1 forum post, maar misschien netjes om dat ook even te melden.
 
Brecht S

Brecht S

04/07/2014 22:29:00
Quote Anchor link
Inderdaad ik heb mij daar ook even aangemeld. Ik zal dat in het vervolg even vermelden.
Kan iemand mij hier helpen?
 
Frank Nietbelangrijk

Frank Nietbelangrijk

04/07/2014 22:51:25
Quote Anchor link
Waar is je javascript? Want zonder javascript is er geen AJAX mogelijk.
Waarom variabelen tussen quotes?
Gewijzigd op 04/07/2014 22:53:03 door Frank Nietbelangrijk
 
Brecht S

Brecht S

04/07/2014 23:59:12
Quote Anchor link
Lijn 174 tot 176 zijn de js files. Ik heb de code grotendeels gekopieerd van iets wat ik had gevonden op het net. Op deze manier werkt het wel maar het kan waarschijnlijk wel stukken beter geschreven worden. Daar ben ik mij van bewust. Kan jij mij hier verder mee helpen? Voor mijn part mag die ajax er volledig uit als we dit kunnen vervangen door jquery.
 
Frank Nietbelangrijk

Frank Nietbelangrijk

05/07/2014 13:02:54
Quote Anchor link
Oké.

Die regels horen in het <head></head> gedeelte.
JQuery voorziet inderdaad al in AJAX functies waar je gebruik van kunt maken. Als je daar hulp bij wilt dan is het zinvol om je javascript ook even te posten.

Opmerkelijk vind ik het dat je de ajax requests naar hetzelfde PHP bestand laat aanroepen. Ik zou het overzichtelijker vinden als daar een apart PHP bestand voor werd aangeroepen.

Even terug naar je eerste vragen:
Beiden vragen zijn eigenlijk min of meer HTML/CSS vragen.

Op regel 108 echo je $response. die zou dan naar beneden moeten.

Kijk eens in je browser naar de bron van de pagina, dan zie je de HTML die je script aanmaakt. Is deze HTML wel helemaal correct? Ook kun je je HTML door de 'W3C validator' halen.

Verder nog wat algemene tips:
-hou HTML, CSS, PHP en Javascript zo veel mogelijk van elkaar gescheiden. Plaats deze dus zo veel mogelijk in aparte bestanden. Als je PHP en HTML in één bestand wilt houden, Plaats alle PHP dan bovenin en de HTML helemaal onderin. Tussen de HTML komt dan hier en daar alleen een heel klein stukje PHP om variabelen te echoën.
 
Brecht S

Brecht S

05/07/2014 14:00:49
Quote Anchor link
Ik post even mijn javascripts hieronder. Oorspronkelijk stond dit ook allemaal in 1 file dus heb ik dat zo gelaten, maar wil dat wel scheiden indien beter. Ik heb die $response al eens naar beneden gezet maar dan lukt het helemaal niet meer.
@ Frank: kan jij me helpen aan een oplossing voor mijn vragen? De database query's zijn wel heel erg belangrijk dus die moeten er zeker blijven in zitten (hetgeen nu in de ajax gebeurd, maar mag gerust met jquery gebeuren).

functions.js file:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
function SimpleAJAXCallback(in_text, obj) {
    document.getElementById(obj).innerHTML = in_text;
    setStatus ("","showimg");
    setStatus ("","showimg2");
}

function checkAll(checkname, exby) {
var bgcolor = 'ffffff';
  for (i = 0; i < checkname.length; i++) {
  checkname[i].checked = exby.checked? true:false
  var cell = document.getElementById('row' + i);
    if (bgcolor == 'eeeeee') {
        var bgcolor = 'ffffff';
    } else {
        var bgcolor = 'eeeeee';
    }
    if (checkname[i].checked) {
        cell.style.background = '#cccccc';
    } else {
        cell.style.background = '#' + bgcolor;
    }
  }
}

function checktoggle(box,theId,color) {
if(document.getElementById) {
var cell = document.getElementById(theId);
var box = document.getElementById(box);
if(box.checked) {
cell.style.background = '#cccccc';
} else {
cell.style.background = '#' + color;
}
}
}

function checktoggle_over(box,theId,color) {
if(document.getElementById) {
var cell = document.getElementById(theId);
var box = document.getElementById(box);
cell.style.background = '#' + color;
}
}


function findPosX(obj){
    var curleft = 0;
    if (obj.offsetParent){
        while (obj.offsetParent){
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    } else if (obj.x){
        curleft += obj.x;
    }
    return curleft;
}

function findPosY(obj){
    var curtop = 0;
    if (obj.offsetParent){
        while (obj.offsetParent){
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    } else if (obj.y){
        curtop += obj.y;
    }
    return curtop;
}

//Function to set a loading status.
function setStatus (theStatus, theObj){
    obj = document.getElementById(theObj);

    if (obj) {
    
    if (theStatus == 1){
        obj.innerHTML = "<div align=right>" + "<img src=\"/i/images/loading.gif\" alt=\"Loading\" vspace=2 hspace=2>" + "</div>";
    } else {
        obj.innerHTML = "<div align=right>" + "" + "</div>";
    }

    }
}
    

function doneloading(theframe,thefile){
    var theloc = ""
    theframe.processajax ("showimg",theloc);
}


function popup(mylink, windowname, windowwidth, windowheight){
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=' + windowwidth + ',height=' + windowheight + ',scrollbars=yes,resizable=yes');
return false;
}    


var qsParm = new Array();

function qs(serverPage) {

    var query = serverPage;
    var parms = query.split('&');

    for (var i=0; i<parms.length; i++) {

        var pos = parms[i].indexOf('=');

        if (pos > 0) {

            var key = parms[i].substring(0,pos);
            var val = parms[i].substring(pos+1);
            qsParm[key] = val;

        }    
    }
}




ajax_queue.js file:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
var    g_ajax_obj = new c_ajax_object;    // This will be the gobal AJAX object. There can be only one...

/******************************************************************
    This class handles "queueing" objects in a pseudo-asynchronous fashion.
    Ajax can't actually handle multiple streams, so we "queue" the requests
    to execute one after another.
*/
function c_ajax_object() {
    // THIS SPACE FOR RENT
};

// Initialize up the prototype fields.

c_ajax_object.prototype._dm_xmlhttprequest_type=null;        // Used when trying for the correct XMLHTTP object type.
c_ajax_object.prototype._dm_xmlhttprequestobject=null;    // This is the HTTP Request Object for this instance.
c_ajax_object.prototype._dm_callback_function=null;        // The function to be called upon completion of a request.
c_ajax_object.prototype._dm_param=null;                        // An additional parameter to be passed to the function
c_ajax_object.prototype._dm_partialcallback_function=null;    // A function to be called for the interactive phase
c_ajax_object.prototype._dm_param2=null;                        // An additional parameter to be passed to that function
c_ajax_object.prototype._dm_phase=0;                            // The phase during which this function is called (Default 3).
c_ajax_object.prototype._dm_queue=new Array();                // This is the queue
c_ajax_object.prototype._dm_queue_state=true;                // This is the queue state
                                                                            //     false = paused
                                                                            //     true = normal
c_ajax_object.prototype._dm_committed=false;                    // This is set to true when the HTTPRequest reaches Stage 3.
c_ajax_object.prototype._dm_pre_queue_in_url=null;            // These are all used for the "pre-queue."
c_ajax_object.prototype._dm_pre_queue_in_callback=null;
c_ajax_object.prototype._dm_pre_queue_in_method=null;
c_ajax_object.prototype._dm_pre_queue_in_param=null;
c_ajax_object.prototype._dm_pre_queue_in_pcallback=null;
c_ajax_object.prototype._dm_pre_queue_in_param2=null;
c_ajax_object.prototype._dm_pre_queue_in_c2_phase=0;

/******************************************************************
    Constructs a new HTTP Request object. IE and the rest of the
    world have different ideas about what constitutes an HTTP
    Request class, so we deal with that here.
    
    We use the conditional Jscript stuff that IE supports to create
    an *.XMLHTTP object, or the standard Mozilla/Netscape XMLHttpRequest object.
    
    We use this as a test. If this object can't create the HTTP request object
    (either XMLHttpRequest or *.XMLHTTP), then the browser can't handle AJAX.
*/

// New version, created by Jeremy Lucier
c_ajax_object.prototype.GetNewRequestObject = function() {
    // check the dom to see if this is IE or not
    if (window.XMLHttpRequest) {
        // Not IE
        this._dm_xmlhttprequestobject = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        // Hello IE!
        // Instantiate the latest MS ActiveX Objects
        if (this._dm_xmlhttprequest_type) {
            this._dm_xmlhttprequestobject = new ActiveXObject(this._dm_xmlhttprequest_type);
        } else {
            // loops through the various versions of XMLHTTP to ensure we're using the latest
            var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
            for (var i = 0; i < versions.length ; i++) {
             try {
                    // try to create the object
                        // if it doesn't work, we'll try again
                        // if it does work, we'll save a reference to the proper one to speed up future instantiations
                    this._dm_xmlhttprequestobject = new ActiveXObject(versions[i]);
                    if (this._dm_xmlhttprequestobject) {
                        this._dm_xmlhttprequest_type = versions[i];
                        break;
                    }
            }
            catch (objException) {
                // trap; try next one
                };
            };
        }
    }
};

// Original Function
// c_ajax_object.prototype.GetNewRequestObject = function() {
//     /*
//         All this whacky stuff is for Internet Exploder.
//         IE uses conditional macros, so we first try to create an IE request
//         object, using their macros. If this succeeds, then we don't try to
//         do it the other way.
//         This came from http://swik.net/
//     */
//     /*@cc_on @*/
//     
//     /*@if (@_jscript_version >= 5)
//         try {
//             this._dm_xmlhttprequestobject = new ActiveXObject("Msxml2.XMLHTTP");
//             }
//         catch (e) {
//             try {
//                 this._dm_xmlhttprequestobject = new ActiveXObject("Microsoft.XMLHTTP");
//                 }
//             catch (e2) {
//                 this._dm_xmlhttprequestobject = false;
//                 }
//             }
//     @end @*/
//     
//     if ( !this._dm_xmlhttprequestobject && (typeof XMLHttpRequest != 'undefined') ) {
//         this._dm_xmlhttprequestobject = new XMLHttpRequest();
//         }
// };

/******************************************************************
    Kills the Queue (non-negotiable cancel).
    If there is still an HTTPRequest out there, it will allow that to complete.
*/

c_ajax_object.prototype.QueueFlush = function ( ) {
    this._dm_queue = new Array();
    this.QueueResume();    // If the queue was paused, it is now re-enabled
}

/******************************************************************
    This pauses the queue by clearing a semaphore.
    If there is still an HTTPRequest out there, it will allow that to complete.
*/

c_ajax_object.prototype.QueuePause = function ( ) {
    this._dm_queue_state = false;
}

/******************************************************************
    This re-enables the queue. It calls Dequeue() to start the chain
    going again.
*/

c_ajax_object.prototype.QueueResume = function ( ) {
    this._dm_queue_state = true;
    this.Dequeue();
}

/******************************************************************
    This bypasses the queue, and injects an HTTPRequest right in.
    This is a dangerous call, as it wipes out any command currently
    being run.
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_method:        The HTTP method to use (default is GET).
        in_param:        A parameter (any type) that is passed into the callback
        in_pcallback:    Partial callback
        in_param2:        A second parameter for the partial callback
        in_phase:        The phase during which the second callback will be made (1-3), Default is 3.
*/

c_ajax_object.prototype.QueueInterrupt = function ( in_url, in_callback, in_method, in_param, in_pcallback, in_param2, in_phase ) {
    var url = in_url;
    this._dm_callback_function = in_callback;    // The basic callback
    var method = in_method;
    this._dm_param = in_param;    // If there is a parameter, we get it here.
    this._dm_partialcallback_function = in_pcallback;    // If there is a partial callback, we get it here.
    this._dm_param2 = in_param2;    // If there is a second parameter, we get it here.
    this._dm_phase = in_phase;    // If there is a second parameter, we get it here.
    
    if ( url && method ) {
        ret = this._CallXMLHTTPObject ( url, method );
        }
    
    return ret;
}

/******************************************************************
    This is a gentler version of the above. It injects the command
    as the next one to be processed, cutting the line.
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_method:        The HTTP method to use (default is GET).
        in_param:        A parameter (any type) that is passed into the callback
        in_pcallback:    Partial callback
        in_param2:        A second parameter for the partial callback
        in_phase:        The phase during which the second callback will be made (1-3), Default is 3.
*/

c_ajax_object.prototype.QueueInject = function ( in_url, in_callback, in_method, in_param, in_pcallback, in_param2, in_phase ) {

    this._dm_queue_state = false;

    // Move the queue up one to make room at the start.
    for ( var counter = this._dm_queue.length; counter > 0; counter-- ) {
        this._dm_queue[counter] = this._dm_queue[counter - 1];
        }
        
    this._dm_queue[0] = new Array ( in_url, in_callback, in_method, in_param, in_pcallback, in_param2, in_phase );

    this._dm_queue_state = true;    // We don't call DeQueue, so we won't interrupt any request in progress.
}

/******************************************************************
    Basic Ajax Call for GET method
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
*/

c_ajax_object.prototype.CallXMLHTTPObjectGET = function ( in_url, in_callback ) {
    return this.CallXMLHTTPObject ( in_url, in_callback, "GET", null, null, 0 );
}

/******************************************************************
    Basic Ajax Call for GET method (with additional parameter)
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_param:        A parameter (any type) that is passed into the callback
                            This parameter is used to pass things such as a field ID,
                            etc. to the callback, and can be used to propagate a
                            context. Callbacks tend to be free of context, so this
                            helps to get around that problem.
*/

c_ajax_object.prototype.CallXMLHTTPObjectGETParam = function ( in_url, in_callback, in_param ) {
    return this.CallXMLHTTPObject ( in_url, in_callback, "GET", in_param, null, 0 );
}

/******************************************************************
    Basic Ajax Call for GET method (with additional parameter and partial callback)
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_param:        A parameter (any type) that is passed into the callback
                            This parameter is used to pass things such as a field ID,
                            etc. to the callback, and can be used to propagate a
                            context. Callbacks tend to be free of context, so this
                            helps to get around that problem.
        in_pcallback:    This specifies a "partial callback" function that is called
                            when the request reaches Phase 3 (interactive).
        in_param2:        A second parameter for the partial callback
*/

c_ajax_object.prototype.CallXMLHTTPObjectGETParamPartial = function ( in_url, in_callback, in_param, in_pcallback, in_param2 ) {
    return this.CallXMLHTTPObject ( in_url, in_callback, "GET", in_param, in_pcallback, in_param2, 0 );
}

/******************************************************************
    Basic Ajax Call for GET method (with additional parameter, partial
    callback and partial callback phase)
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_param:        A parameter (any type) that is passed into the callback
                            This parameter is used to pass things such as a field ID,
                            etc. to the callback, and can be used to propagate a
                            context. Callbacks tend to be free of context, so this
                            helps to get around that problem.
        in_pcallback:    This specifies a "partial callback" function that is called
                            when the request reaches Phase 3 (interactive).
        in_param2:        A second parameter for the partial callback
        in_phase:        The request phase (1-3) during which the partial callback is made.
*/

c_ajax_object.prototype.CallXMLHTTPObjectGETParamPartialPhase = function ( in_url, in_callback, in_param, in_pcallback, in_param2, in_phase ) {
    return this.CallXMLHTTPObject ( in_url, in_callback, "GET", in_param, in_pcallback, in_param2, in_phase );
}

/******************************************************************
    Basic Ajax Call for POST method
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
*/

c_ajax_object.prototype.CallXMLHTTPObjectPOST = function ( in_url, in_callback ) {
    return this.CallXMLHTTPObject ( in_url, in_callback, "POST", null, null, 0 );
}

/******************************************************************
    Basic Ajax Call for POST method (with additional parameter)
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_param:        A parameter (any type) that is passed into the callback
                            This parameter is used to pass things such as a field ID,
                            etc. to the callback, and can be used to propagate a
                            context. Callbacks tend to be free of context, so this
                            helps to get around that problem.
*/

c_ajax_object.prototype.CallXMLHTTPObjectPOSTParam = function ( in_url, in_callback, in_param ) {
    return this.CallXMLHTTPObject ( in_url, in_callback, "POST", in_param, null, 0 );
}

/******************************************************************
    Basic Ajax Call for POST method (with additional parameter and partial callback)
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_param:        A parameter (any type) that is passed into the callback
                            This parameter is used to pass things such as a field ID,
                            etc. to the callback, and can be used to propagate a
                            context. Callbacks tend to be free of context, so this
                            helps to get around that problem.
        in_pcallback:    This specifies a "partial callback" function that is called
                            when the request reaches Phase 3 (interactive).
        in_param2:        A second parameter for the partial callback
*/

c_ajax_object.prototype.CallXMLHTTPObjectPOSTParamPartial = function ( in_url, in_callback, in_param, in_pcallback, in_param2 ) {
    return this.CallXMLHTTPObject ( in_url, in_callback, "POST", in_param, in_pcallback, in_param2, 0 );
}

/******************************************************************
    Basic Ajax Call for POST method (with additional parameter, partial
    callback and partial callback phase)
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_param:        A parameter (any type) that is passed into the callback
                            This parameter is used to pass things such as a field ID,
                            etc. to the callback, and can be used to propagate a
                            context. Callbacks tend to be free of context, so this
                            helps to get around that problem.
        in_pcallback:    This specifies a "partial callback" function that is called
                            when the request reaches Phase 3 (interactive).
        in_param2:        A second parameter for the partial callback
        in_phase:        The request phase (1-3) during which the partial callback is made.
*/

c_ajax_object.prototype.CallXMLHTTPObjectPOSTParamPartialPhase = function ( in_url, in_callback, in_param, in_pcallback, in_param2, in_phase ) {
    return this.CallXMLHTTPObject ( in_url, in_callback, "POST", in_param, in_pcallback, in_param2, in_phase );
}

/******************************************************************
    Prime a call to the queue
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_method:        The HTTP method to use (default is GET).
        in_param:        A parameter (any type) that is passed into the callback
        in_pcallback:    Partial callback
        in_param2:        A second parameter for the partial callback
        in_phase:        The phase during which the second callback will be made (1-3), Default is 3.
*/

c_ajax_object.prototype.CallXMLHTTPObject = function ( in_url, in_callback, in_method, in_param, in_pcallback, in_param2, in_phase ) {
    // Set up the "pre queue."
    this._dm_pre_queue_in_url=in_url;
    this._dm_pre_queue_in_callback=in_callback;
    this._dm_pre_queue_in_method=in_method;
    this._dm_pre_queue_in_param=in_param;
    this._dm_pre_queue_in_pcallback=in_pcallback;
    this._dm_pre_queue_in_param2=in_param2;
    this._dm_pre_queue_in_c2_phase=in_phase;
    if ( (this._dm_pre_queue_in_c2_phase < 1) || (this._dm_pre_queue_in_c2_phase > 3) ) {
        this._dm_pre_queue_in_c2_phase = 3;
        }
    this.Enqueue();
    return true;
};

/******************************************************************
    Add a call to the queue
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_method:        The HTTP method to use (default is GET).
        in_param:        A parameter (any type) that is passed into the callback
        in_pcallback:    Partial callback
        in_param2:        A second parameter for the partial callback
*/

c_ajax_object.prototype.Enqueue = function ( ) {
    // Set up the main queue from the prequeue.
    this._dm_queue[this._dm_queue.length] = new Array ( this._dm_pre_queue_in_url, this._dm_pre_queue_in_callback,
        this._dm_pre_queue_in_method, this._dm_pre_queue_in_param, this._dm_pre_queue_in_pcallback,
        this._dm_pre_queue_in_param2, this._dm_pre_queue_in_c2_phase );
    
    // As you were...
    this._dm_pre_queue_in_url=null;
    this._dm_pre_queue_in_callback=null;
    this._dm_pre_queue_in_method=null;
    this._dm_pre_queue_in_param=null;
    this._dm_pre_queue_in_pcallback=null;
    this._dm_pre_queue_in_param2=null;
    this._dm_pre_queue_in_c2_phase=0;
        
    // If there are no other commands in progress, we start the daisy-chain.
    if ( !this._dm_xmlhttprequestobject ) {
        this.Dequeue();
        }
};

/******************************************************************
    Dequeue and execute
*/

c_ajax_object.prototype.Dequeue = function ( ) {
    var command = null;
    var ret=false;
    
    if ( this._dm_queue.length && this._dm_queue_state ) {
        command = this._dm_queue[0];
        
        var url = command[0];
        this._dm_callback_function = command[1];    // The basic callback
        var method = command[2];
        this._dm_param = command[3];    // If there is a parameter, we get it here.
        this._dm_partialcallback_function = command[4];    // If there is a partial callback, we get it here.
        this._dm_param2 = command[5];    // If there is a second parameter, we get it here.
        this._dm_phase = command[6];    // If there is a second parameter, we get it here.
        
        for ( var counter = 1; counter < this._dm_queue.length; counter++ ) {
            this._dm_queue[counter - 1] = this._dm_queue[counter];
            }
        
        this._dm_queue.length = counter - 1;
        }
    
    if ( url && method ) {
        ret = this._CallXMLHTTPObject ( url, method );
        }
    
    return ret;
};

/******************************************************************
    Basic low-level Ajax Call
    
    Params:
        in_url:             The URL to call
        in_callback:    A function to be called upon completion
        in_method:        The HTTP method to use (default is GET).
*/

c_ajax_object.prototype._CallXMLHTTPObject = function ( in_url, in_method ) {
    try {
        var sVars = null;
        
        // Split the URL up, if this is a POST.
        if ( in_method == "POST" ) {
            var rmatch = /^([^\?]*)\?(.*)$/.exec ( in_url );
            in_url = rmatch[1];
            sVars = unescape ( rmatch[2] );
            }
        
        this._dm_committed = false;
        this.GetNewRequestObject();
        this._dm_xmlhttprequestobject.open(in_method, in_url, true);
        
        if ( in_method == "POST" ) {
          this._dm_xmlhttprequestobject.setRequestHeader("Method", "POST "+in_url+" HTTP/1.1");
          this._dm_xmlhttprequestobject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            }
        
        this._dm_xmlhttprequestobject.onreadystatechange = Handle_HTTP_Response;
        this._dm_xmlhttprequestobject.send(sVars);
        
        return true;
        }
    catch ( z ) { }
    
    return false;
};

/******************************************************************
    This is the callback router. This is set as the callback in the
    request object, and it then routes the callback to the one provided
    by the calling context. It uses the global object to associate the
    parameters provided to the callback.
    
    This is a fairly typical pattern used by "faux OOP" systems. I call
    the pattern FALSE OBJECT. It allows a procedural language to establish
    an object context. Javascript is (sort of) object-oriented, but HTTP
    requests are not. When you get a callback from an HTTP Request, it is
    context-free. I use the SINGLETON global object to re-establish a
    context, and restore the object-oriented code.
    
    Note the partial callback we make. We can choose the stage at which
    this partial callback is made. Default is 3 (Interactive). You cannot
    make a partial callback at Stage 0.
*/

function Handle_HTTP_Response () {
    /*
        Okay, what I needed to do was test for IE. If you even take a peek at the responseText or responseBody fields
        during an incomplete request (0 - 3), in Windows IE 6 or IE 7, you get a JavaScript error. If the UA is IE,
        then I skip looking at the field (That's what all that stuff with "resp" down there is for).
        
        The long and the short of it is that you get no reliable responseText in IE. You will get your callback, along
        with the partial callback parameter you sent, but no text. Mozilla/KDE will give you text as of Stage 3.
    */
    var ie = navigator.appName=='Microsoft Internet Explorer';    // Are we IE?
    
    if ( g_ajax_obj && g_ajax_obj._dm_xmlhttprequestobject ) {    // Don't even bother if we don't have a request object to use.
        if ( g_ajax_obj._dm_xmlhttprequestobject.readyState == 0 ) {    // Uninitialized (sent, but no information yet)
            }
        else {
            if ( g_ajax_obj._dm_xmlhttprequestobject.readyState == 1 ) {    // Loading (probably received)
                if ( g_ajax_obj._dm_phase == g_ajax_obj._dm_xmlhttprequestobject.readyState ) {
                    if ( g_ajax_obj._dm_partialcallback_function ) {
                        var resp;    // This is all about the IE fix mentioned above.
                        if(!ie && g_ajax_obj._dm_xmlhttprequestobject.responseText){
                            resp=g_ajax_obj._dm_xmlhttprequestobject.responseText;
                            }
                        g_ajax_obj._dm_partialcallback_function ( resp, g_ajax_obj._dm_param2 ? g_ajax_obj._dm_param2 : g_ajax_obj._dm_param );
                        }
                    }
                }
            else {
                if ( g_ajax_obj._dm_xmlhttprequestobject.readyState == 2 ) {    // Loaded (received for sure, but no further data)
                    // At this point, the server has the request, and is executing it (probably).
                    if ( g_ajax_obj._dm_phase == g_ajax_obj._dm_xmlhttprequestobject.readyState ) {
                        if ( g_ajax_obj._dm_partialcallback_function ) {
                            var resp;
                            if(!ie && g_ajax_obj._dm_xmlhttprequestobject.responseText){
                                resp=g_ajax_obj._dm_xmlhttprequestobject.responseText;
                                }
                            g_ajax_obj._dm_partialcallback_function ( resp, g_ajax_obj._dm_param2 ? g_ajax_obj._dm_param2 : g_ajax_obj._dm_param );
                            }
                        }
                    }
                else {
                    if ( g_ajax_obj._dm_xmlhttprequestobject.readyState == 3 ) {    // Interactive
                        // At this point, the server has the request, and is executing it. A partial response MAY be available
                        // in the g_ajax_obj._dm_xmlhttprequestobject.responseText and g_ajax_obj._dm_xmlhttprequestobject.responseBody
                        // fields.
                        // We have the option of sending a "Partial Callback" function, which we can use to do things like
                        // disable a button to prevent additional requests.
                        g_ajax_obj._dm_committed = true;
                        if ( g_ajax_obj._dm_phase == g_ajax_obj._dm_xmlhttprequestobject.readyState ) {
                            if ( g_ajax_obj._dm_partialcallback_function ) {
                                var resp;
                                if(!ie && g_ajax_obj._dm_xmlhttprequestobject.responseText){
                                    resp=g_ajax_obj._dm_xmlhttprequestobject.responseText;
                                    }
                                g_ajax_obj._dm_partialcallback_function ( resp, g_ajax_obj._dm_param2 ? g_ajax_obj._dm_param2 : g_ajax_obj._dm_param );
                                }
                            }
                        }
                    else {
                        if ( g_ajax_obj._dm_xmlhttprequestobject.readyState == 4 ) {    // We're done. Back to you.
                            // We send both parameters, just in case they both apply (for example, the partial disables a field,
                            // so the complete one re-enables it).
                            g_ajax_obj._dm_callback_function ( g_ajax_obj._dm_xmlhttprequestobject.responseText, g_ajax_obj._dm_param, g_ajax_obj._dm_param2 );
                            if( typeof g_ajax_obj != 'undefined' ) { // Just in case they nuked the object in the callback.
                                g_ajax_obj._dm_xmlhttprequestobject = null;    // Kill the request object. we're done.
                                g_ajax_obj._dm_committed = false;
                                g_ajax_obj._dm_phase = 0;
                                g_ajax_obj.Dequeue();
                                }
                            }
                        }
                    }
                }
            }
        }
return true;
};

/******************************************************************
    Returns true if the browser will support Ajax
    
    Very simple. We just create a request object. If it succeeds, we're in like Flint.
*/

if (typeof SupportsAjax == 'undefined'){    // In case we included ajax_threads.js
    function SupportsAjax ( ) {
        var test_obj = new c_ajax_object;
        
        if( typeof test_obj != 'undefined' ) {
            test_obj.GetNewRequestObject();
            
            if ( test_obj._dm_xmlhttprequestobject ) {
                test_obj._dm_xmlhttprequestobject = null;
                test_obj = null;
                return true;
                }
            
            test_obj = null;
            }
        
        return false;
    };
}

/******************************************************************
    Completely simplified AJAX Call. Just add a callback.
    
    Params:
        in_uri:             The URI to call. Even if it is a POST, you
                            specify the URI as if it were a GET. The class
                            will take care of stripping out the parameters.
                            This parameter is required.
                            
        in_callback:    A function to be called upon completion
                            Your callback should have the following format:
                            
                            function Callback(in_string)
                            
                            You don't have to worry about a parameter, as
                            none will be sent in this simplified callback.
                            This parameter is required.
                            
        in_method:        The HTTP method to use (default is GET).
                            Must be either 'GET' or 'POST' (case-insensitive)
                            This parameter is optional.
                            
        in_param:        A "context keeper" parameter. This will be passed
                            into your callback.
                            This parameter is optional.
                            
    Function return:
        true if the call was successfully queued (not actually sent as
        a request), false if there was any type of error. The type of
        error is not specified. It could be a required parameter was not
        sent in, the browser does not support AJAX, or there was an issue
        with the queue mechanism.
*/

function SimpleAJAXCall ( in_uri, in_callback, in_method, in_param ) {
    // The method indicator is actually optional, so we make it GET if nothing was passed.
    if ( (typeof in_method == 'undefined') || ((in_method != 'GET')&&(in_method != 'POST')) ) {
        in_method = 'GET';
        }

    //setStatus ("1","showimg");
    //setStatus ("1","showimg2");
    
    in_method = in_method.toUpperCase();
    
    // We verify that the proper parameters have been passed in.
    if ( SupportsAjax() && (typeof in_uri != 'undefined') && in_uri && (typeof in_callback == 'function') ) {
        if ( in_method == 'POST' ) {
            return g_ajax_obj.CallXMLHTTPObjectPOSTParam ( in_uri, in_callback, in_param );
            } else {
            return g_ajax_obj.CallXMLHTTPObjectGETParam ( in_uri, in_callback, in_param );
            }
        } else {
            return false;
        }
};
 
Bas IJzelendoorn

Bas IJzelendoorn

05/07/2014 14:34:09
Quote Anchor link
Zou je enkel relevante code willen plaatsen? 650 regels plus de regels die je eerder al hebt geplaatst zullen mensen niet snel even doorakkeren. Als je enkel relevante code plaatst kunnen mensen die in dit topic komen zich sneller inlezen, waardoor je mogelijk sneller een antwoord hebt. Dit schrikt nu heel erg af.[/modedit]
Gewijzigd op 05/07/2014 14:34:52 door Bas IJzelendoorn
 
Brecht S

Brecht S

05/07/2014 14:55:56
Quote Anchor link
De laatste 2 files zijn de javascripten die gebruikt worden om de ajax aan te spreken en allerlei functie die gebruikt worden. De eerste code die geplaatst is si de volledige code nodig om de kalender te laten werken, dus begrijp niet goed welke stukken ik er kan uithalen om te laten zien?
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.