-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata1.js
More file actions
63 lines (58 loc) · 1.31 KB
/
Copy pathdata1.js
File metadata and controls
63 lines (58 loc) · 1.31 KB
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
//New File Editied
var xmlData=createNewXmlData();
function createNewXmlData(){
var xmlData;
if(window.ActiveXObject){
try{
xmlData=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
xmlData=false;
}
}
else{
try{
xmlData=new XMLHttpRequest();
}
catch(e){
xmlData=false;
}
}
if(!xmlData){
alert('cannot create object');
}
else{
return xmlData;
}
}
function process1() {
var xhttp = new XMLHttpRequest();
food = (document.getElementById("inputBox").value);
xhttp.onreadystatechange =handleServerResponse();
xhttp.open("GET", "data.php?food="+food, true);
xhttp.send();
}
function process(){
if(xmlData.readyState==0 || xml.readyState==4){
food = (document.getElementById("inputBox").value);
xmlData.open("GET", "data.php?food=" +food, true);
xmlData.onreadystatechange=handleServerResponse;
xmlData.send();
}
else{
setTimeout('process()',100);
}
}
function handleServerResponse(){
if(xmlData.readyState==4){
if(xmlData.status==200){
xmlResponse=xmlData.responseXML;
xmlDocumentElement=xmlResponse.documentElement;
message=xmlDocumentElement.firstChild.data;
document.getElementById("displayData").innerHTML='<span style="color:blue">'+message+ '</span>';
setTimeout('process()',100);
}
else{
alert('something wnent wrong');
}
}
}