1
0
Fork 0
forked from 0x2620/oxjs

add app.request, extend demo

This commit is contained in:
j 2010-01-27 18:55:37 +05:30
commit d9848bacf7
3 changed files with 86 additions and 55 deletions

View file

@ -6,19 +6,26 @@
<script type="text/javascript" src="../../build/js/ox.ui.js"></script>
<script type="text/javascript">
$(function() {
var app = new Ox.App().launch();
Ox.Request.send({
url: "http://blackbook.local:8000/api/",
data: {
"function": "hello",
data: JSON.stringify({key: "value"})
},
callback: function(data) {
console.log(data);
var app = new Ox.App({
requestURL:"http://blackbook.local:8000/api/"
});
app.request('hello');
app.request('login', {'username':'test', 'password':'test'}, function(result) {
Ox.print(result);
if(result.status.code == 200) {
Ox.print(result);
app.request('preferences', function(result) {
Ox.print(result.data.preferences);
});
}
else if(result.status.code == 403) {
alert('login failed');
} else {
Ox.print('broken');
}
});
});
</script>
</head>
<body></body>
</html>
</html>