Dictionarys werden von bottle automatisch als Typ 'application/json' ausgeliefert, das funktioniert auch. Wenn ich mein javascript ausführe, geht auch ein request an meinen bottle-server. Aber statt alert('whoooo es geht'), lande ich immer beim error. Was mache ich falsch?
Code: Alles auswählen
@route('/json/test')
def show_json():
return {'TestA':'Ich bin Test A.', 'TestB':'Ich bin Test B.'}
Code: Alles auswählen
<script type="text/javascript">
$.ajax({
type: "GET",
url: "http://127.0.0.1:8080/json/test",
dataType: 'json',
success: function(data){
alert('whoooo es geht');
},
error: function(o,c,m) { alert(m); }
});
</script>
Code: Alles auswählen
Bottle v0.11.dev server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.
localhost - - [07/May/2012 14:17:28] "GET /json/test HTTP/1.1" 200 56
localhost - - [07/May/2012 14:19:32] "GET /json/test HTTP/1.1" 200 56