forked from aniket-cr/research-bros
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajaxLab.js
More file actions
75 lines (70 loc) · 2.21 KB
/
ajaxLab.js
File metadata and controls
75 lines (70 loc) · 2.21 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
64
65
66
67
68
69
70
71
72
73
74
75
function addLabArg(emailID,name,description)
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var response = xmlhttp.responseText;
console.log(response);
response = JSON.parse(response);
console.log(response);
document.getElementById("emailField").value = response.emailID;
console.log(response.emailID);
document.getElementById("nameField").value = response.name;
console.log(response.name);
document.getElementById("contactField").value = response.contact;
//document.getElementById("addressField").value = response.address;
//document.getElementById("text").innerHTML=xmlhttp.responseText['a'];
console.log(xmlhttp.responseText);
}
}
var parameters = "emailID=" + emailID + "&add_lab=1&name=" + name + "&description=" + description;
console.log(parameters);
xmlhttp.open("POST","lab_operations.php?" + parameters ,true);
xmlhttp.send();
}
function displayLabsArg(emailID)
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var response = xmlhttp.responseText;
console.log(response);
response = JSON.parse(response);
var result = "<table>";
for(var i=0;i<response.length;i++)
{
result = result + "<tr> <td>" + response[i]["name"] + "</td> <td> " + response[i]["description"] +
"</td> </tr>";
}
result = result + "</table>";
document.getElementById("display_labs").innerHTML = result;
console.log(result);
//document.getElementById("addressField").value = response.address;
//document.getElementById("text").innerHTML=xmlhttp.responseText['a'];
}
}
var parameters = "emailID=" + emailID + "&add_lab=0";
console.log(parameters);
xmlhttp.open("POST","lab_operations.php?" + parameters ,true);
xmlhttp.send();
}