01.
function
createXML(){
02.
var
xmlHttp =
null
;
03.
if
(window.ActiveXObject){
04.
try
{
05.
xmlHttp =
new
ActiveXObject(
"Microsoft.xmlHttp"
);
06.
}
catch
(e) {
07.
xmlHttp =
false
;
08.
}
09.
}
else
{
10.
try
{
11.
xmlHttp =
new
xmlHttpRequest();
12.
alert(
"firefox"
);
13.
}
catch
(e) {
14.
xmlHttp =
false
;
15.
}
16.
}
17.
if
(!xmlHttp){
18.
alert(
"ไม่สามารถสร้าง object Ajax นี้ได้"
);
19.
}
20.
else
{
21.
return
xmlHttp;
22.
}
23.
}
24.
25.
function
telephone(){
26.
xmlHttp = createXML();
27.
url =
"telephone.jsp"
;
28.
xmlHttp.open(
"get"
,url,
true
);
29.
xmlHttp.send(
null
);
30.
xmlHttp.onreadystatechange=
function
(){
31.
if
(xmlHttp.readyState == 4){
32.
var
status = xmlHttp.responseText;
33.
show = document.getElementById(
"shData"
);
34.
show.innerHTML = status;
35.
}
36.
};
37.
}
38.
39.
function
computer(){
40.
var
xmlHttp=createXML();
41.
xmlHttp.open(
"get"
,
"computer.jsp"
,
true
);
42.
xmlHttp.send(
null
);
43.
xmlHttp.onreadystatechange=
function
(){
44.
if
(xmlHttp.readyState==4){
45.
var
status = xmlHttp.responseText;
46.
var
show = document.getElementById(
"shData"
);
47.
show.innerHTML = status;
48.
}
49.
};
50.
}