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!
--