Chatbox probleem
Ik heb een chatbox probleem.
Het probleem zit bij het AJAX gebeuren.
Hier is de JS code waar de fout waarschijnlijk inzit:
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
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
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
$(document).ready(function() {
$('#chatbox').load('requests/chatbox/read.php').show();
$('#chatbox').css('width', '589px');
$('#chatbox').css('height', '300px');
$('#chatbox').css('overflow', 'auto');
$('#chatbox').css('border', '1px solid #000');
$('#chatbox').css('padding-left', '12px');
$('#chatbox').css('margin-left', '3px');
$('input').css('font-family', 'arial');
var refreshId = setInterval(function() {
$.ajax({
type: "POST",
url: "requests/chatbox/read.php",
dataType: 'html',
success: function() {
$('#chatbox').load('requests/chatbox/read.php').show();
},
error: function() {
alert('Error: IE not supported.');
}
});
}, 900);
$('button#submit').click(function() {
var name = $('input#name').val();
var message = $('input#message').val();
$('input#message').val('');
$.ajax({
type: "POST",
url: "requests/chatbox/write.php",
dataType: 'html',
data: "name=" + name + "&message=" + message,
success: function() {
$('#chatbox').load('requests/chatbox/read.php').show();
},
error: function() {
alert('Error: IE not supported.');
}
});
});
$(document).keyup(function(e) {
if ( e.which == 13 ) {
var name = $('input#name').val();
var message = $('input#message').val();
$('input#message').val('');
$.ajax({
type: "POST",
url: "requests/chatbox/write.php",
dataType: 'html',
data: "name=" + name + "&message=" + message,
success: function() {
$('#chatbox').load('requests/chatbox/read.php').show();
},
error: function() {
alert('Error: IE not supported.');
}
});
}
if ( e.keyCode == 27 ) {
$('input#message').val('');
}
});
$('button#logout').click(function() {
var name = $('input#name').val();
$.ajax({
type: "POST",
url: "requests/chatbox/write.php",
dataType: 'html',
data: "name=Console&message=De gebruiker '" + name + "' is nu uitgelogd.",
success: function() {
$('#chatbox').load('requests/chatbox/read.php').show();
},
error: function() {
alert('Error: IE not supported.');
}
});
$('input#name').val('');
$('input#message').val('');
$('button#logout').hide();
$('input#message').attr('size', '60');
});
$('input#name').keyup(function() {
$('button#logout').show();
$('input#message').attr('size', '47');
});
});
$('#chatbox').load('requests/chatbox/read.php').show();
$('#chatbox').css('width', '589px');
$('#chatbox').css('height', '300px');
$('#chatbox').css('overflow', 'auto');
$('#chatbox').css('border', '1px solid #000');
$('#chatbox').css('padding-left', '12px');
$('#chatbox').css('margin-left', '3px');
$('input').css('font-family', 'arial');
var refreshId = setInterval(function() {
$.ajax({
type: "POST",
url: "requests/chatbox/read.php",
dataType: 'html',
success: function() {
$('#chatbox').load('requests/chatbox/read.php').show();
},
error: function() {
alert('Error: IE not supported.');
}
});
}, 900);
$('button#submit').click(function() {
var name = $('input#name').val();
var message = $('input#message').val();
$('input#message').val('');
$.ajax({
type: "POST",
url: "requests/chatbox/write.php",
dataType: 'html',
data: "name=" + name + "&message=" + message,
success: function() {
$('#chatbox').load('requests/chatbox/read.php').show();
},
error: function() {
alert('Error: IE not supported.');
}
});
});
$(document).keyup(function(e) {
if ( e.which == 13 ) {
var name = $('input#name').val();
var message = $('input#message').val();
$('input#message').val('');
$.ajax({
type: "POST",
url: "requests/chatbox/write.php",
dataType: 'html',
data: "name=" + name + "&message=" + message,
success: function() {
$('#chatbox').load('requests/chatbox/read.php').show();
},
error: function() {
alert('Error: IE not supported.');
}
});
}
if ( e.keyCode == 27 ) {
$('input#message').val('');
}
});
$('button#logout').click(function() {
var name = $('input#name').val();
$.ajax({
type: "POST",
url: "requests/chatbox/write.php",
dataType: 'html',
data: "name=Console&message=De gebruiker '" + name + "' is nu uitgelogd.",
success: function() {
$('#chatbox').load('requests/chatbox/read.php').show();
},
error: function() {
alert('Error: IE not supported.');
}
});
$('input#name').val('');
$('input#message').val('');
$('button#logout').hide();
$('input#message').attr('size', '60');
});
$('input#name').keyup(function() {
$('button#logout').show();
$('input#message').attr('size', '47');
});
});
Alvast bedankt.
Gewijzigd op 23/08/2011 15:04:28 door Maarten PHP
Zonder een foutmelding te plaatsen zal je weinig reacties krijgen..
In chrome doet hij het, maar in IE niet. Ik bedoel in IE kan ik niet ervoor zorgen dat ik de error krijg of tog wel.
wat doet het niet wanneer?
In IE hetlaad hij de div niet. Zover ik weet.