forked from ArchanaAvv/June2015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajaxAssignment.html
61 lines (53 loc) · 1.52 KB
/
ajaxAssignment.html
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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Ajax Connection Assignment</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"
rel="stylesheet" >
<style>
</style>
</head>
<body>
<table id="studentDataTable" class="table-bordered">
<thead>
<tr class="success">
<th>Name</th>
<th>Title</th>
<th>City</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(function(){
var ajaxConfigure= {
"url": "http://localhost:9300/GetStudents",
"method": "GET",
"success": function(data){
var students = data.studentList;
var dynamicHtml = '';
for(var i = 0; i < students.length; i++){
dynamicHtml += '<tr><td>' + students[i].studentName
+'</td><td>' + students[i].studentTitle + '</td><td>'
+ students[i].studentCity + '</td></tr>';
console.log(dynamicHtml);
}
$('#studentDataTable tbody').append(dynamicHtml);
},
"error": function(jqXHR,textStatus,error){
alert('ajax call error');
},
"dataType": "json",
"complete": function(){
//alert('ajax call complete');
}
};
$.ajax(ajaxConfigure); //making an ajax call
}
)
</script>
</body>
</html>