Skip to content
Browse files

make less confusing

  • Loading branch information...
1 parent 6a0602b commit e3349693c533c17fb9b6a770a8360b64ec337c68 @mcdonc mcdonc committed Jul 9, 2011
Showing with 5 additions and 6 deletions.
  1. +5 −6 docs/narr/webob.rst
11 docs/narr/webob.rst
@@ -256,8 +256,8 @@ does not have a body, or the body is not a properly JSON-encoded value, an
exception will be raised when this attribute is accessed.
This attribute is useful when you invoke a Pyramid view callable via
-e.g. jQuery's ``$.post`` or ``$.ajax`` functions, which have the potential to
-send a JSON-encoded body or parameters.
+e.g. jQuery's ``$.ajax`` function, which has the potential to send a request
+with a JSON-encoded body.
Using ``request.json_body`` is equivalent to:
@@ -275,18 +275,17 @@ is sent to a Pyramid application:
url: 'http://localhost:6543/', // the pyramid server
data: JSON.stringify({'a':1}),
- contentType: 'application/json; charset=utf-8',
- dataType: 'json'});
+ contentType: 'application/json; charset=utf-8'});
When such a request reaches a view in your application, the
``request.json_body`` attribute will be available in the view callable body.
.. code-block:: javascript
- @view_config(renderer='json')
+ @view_config(renderer='string')
def aview(request):
print request.json_body
- return {'result':'OK'}
+ return 'OK'
For the above view, printed to the console will be:

0 comments on commit e334969

Please sign in to comment.
Something went wrong with that request. Please try again.