I think I've looked almost all the examples in google to solve the issue, but still can't get it working well.
My goal is to request data from server after clicking on a button.
The error I get at this moment:
Traceback (most recent call last):
File "/opt/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1546, in __call__
return response(environ, start_response)
TypeError: 'str' object is not callable
INFO 2015-01-04 22:16:52,235 module.py:709] default: "POST /nearest_banks/radius HTTP/1.1" 500 662
My code:
ajax function:
<script type="text/javascript">
$( "#yes" ).click(function() {
$( "#ask_user" ).hide();
$.ajax({
type: "post",
url: '/nearest_banks/radius',
contentType: "application/json; charset=utf-8",
dataType: "json",
// data: { 'names': {{names}}, 'location': {{location}} },
success: function (output) {
output = JSON.parse(output);
("#places").empty();
output.forEach(function (names) {
var $row = $('<p>').appendTo("#places");
});
}});
});
</script>
Python function:
def post(self):
names, location, telephone, check = funcs.Findplaces(default_radius)
dict = {'names': names, 'location': location}
output = json.dumps(dict)
return output
- function Findplaces works well. It returns names, location etc the right way in Unicode type.
These are my urls:
application = webapp2.WSGIApplication([
webapp2.Route(r'/', handler=MainPage, name='mpage', handler_method='get'),
webapp2.Route(r'/nearest_banks', handler=Nearest_banks, name='ne_banks', handler_method='main_func'),
#webapp2.Route(r'/nearest_banks/radius', handler=Nearest_banks, name='ne_banks', handler_method='get'),
webapp2.Route(r'/nearest_banks/radius', handler=Nearest_banks, name='radius', handler_method='post'),
], config=session_module.config, debug=True)
As I understand the error is in the Python def post function .. Please, help me someone to cope with it ...
All I need is to get data from server and show it in some tag on page...