-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestAPI.html
69 lines (57 loc) · 2.4 KB
/
testAPI.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
62
63
64
65
66
67
68
69
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width,initial-scale=1">
<style type="text/css" media="screen">
.error span{background-color:#F00;}
.success span{background-color:#0F0;}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
//var API = 'http://myhotelapi-fpumir.dotcloud.com';
var API = 'http://localhost/myhotelAPI';
var dataType='json';
var test = new Array();
test.push({url:API+'/hotels',type:'GET',dataType:dataType});
test.push({url:API+'/hotels',type:'POST',dataType:dataType});
test.push({url:API+'/hotels',type:'GET',dataType:dataType,data:{name:'opéra'}});
test.push({url:API+'/hotels',type:'GET',dataType:dataType,data:{name:'nord'}});
test.push({url:API+'/hotels/1',type:'GET',dataType:dataType});
test.push({url:API+'/hotels/2',type:'GET',dataType:dataType});
test.push({url:API+'/hotels/3',type:'GET',dataType:dataType});
test.push({url:API+'/booking',type:'GET',dataType:dataType});
test.push({url:API+'/booking',type:'GET',dataType:dataType,data:{account:1}});
test.push({url:API+'/booking/5',type:'GET',dataType:dataType,data:{account:1}});
test.push({url:API+'/booking/4',type:'GET',dataType:dataType,data:{account:1}});
test.push({url:API+'/booking/5',type:'GET',dataType:dataType,data:{account:2}});
test.push({url:API+'/booking/5',type:'POST',dataType:dataType,data:{account:1}});
$(function(){
for(i in test){
$.ajax(test[i])
.always(function(data, status, jqXhr){
var output=$('<pre>');
var url=$('<span>');
var span=this.type+' '+this.url+' => ';
url.append(span);
var pre=status=='success'?JSON.stringify(data):'';
output.append(url).append(pre);
$('.test').append($('<li>').addClass(status).append(output));
})
}
});
</script>
</head>
<body>
test begin:
<ul class="test">
</ul>
test ended
</body>
</html>