Web2py request different behavior on local and online version (server code executes, but returns 404

27 views
Skip to first unread message

Ur. Kr.

unread,
Aug 16, 2016, 7:51:08 PM8/16/16
to web2py-users

On my local version of the application, making the request with the following code, executes the code on the server, returning successfully.

$.ajax({
 type: 'POST',
 url: "{{=URL('default', 'serverFunction.json')}}",
 data: {id: id}
}); 

However, if I make the request like so (without '.json' after serverFunction)

$.ajax({
 type: 'POST',
 url: "{{=URL('default', 'serverFunction')}}",
 data: {id: id}
}); 

The server code executes, but returns a 404 error.

On the online version, it returns a 404 error in both cases, executing the server code.


Cross-posting from here: http://stackoverflow.com/questions/38870171/web2py-request-different-behavior-on-local-and-online-version-server-code-execu

Massimo Di Pierro

unread,
Aug 18, 2016, 3:32:52 PM8/18/16
to web2py-users
Your action returns a dict() which requires a view and the generic.json is not used in production.

replace the return dict() with return response.json(dict())
Reply all
Reply to author
Forward
0 new messages