Well, what are you seeing when you go to the url yourself? On Thursday, October 11, 2012 2:22:03 AM UTC-7, Timo W wrote: > > Hey, > > I want to call a function that I defined in the Controller from javascript > via AJAX. When the function returns a string everything is perfect, but > when it returns > a dict, I get always this error: > > *404 - NOT FOUND > web2py_error:invalid view (default/getValuesFromFile.html)* > > My code looks like this: > > jQuery("#tabs").bind("tabsselect", function(e, tab) { > url = "{{=URL('default', 'indexToSession')}}"; > $.ajax({ //send current index to server > type: "POST", > url: url, > data: { currentTabIndex: tab.index} > }).done(function( msg) { > alert(msg); // this works, as indexToSession only returns > a string > url = "{{=URL('default', 'getValuesFromFile')}}"; > $.ajax({ //get Data to plot > type: "POST", > url: url > }).done(function( data) { > alert(data['names']; // this doesn't work > }); > }); > }); > > And my controller looks like this: > > def getValuesFromFile(): > > [...] > > return dict(title = title, names = name) > > def indexToSession(): > > session.tabindex = int(request.vars.currentTabIndex) > > return session.tabindex > > > I don't get the point why it is not working with dict's. I have tried it > also with the jQuery- Method $.getJSON( ...) and $.get(...) but nothing > worked. > > Can someone give me a hint, why this is not working. > > Would be great! >
--