summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-07-09 21:24:14 -0400
committerChris McDonough <chrism@plope.com>2011-07-09 21:24:14 -0400
commite3349693c533c17fb9b6a770a8360b64ec337c68 (patch)
tree752a780e5da26d67a95d2ccb8c57d8b65a2ca8bf
parent6a0602b3ce4d2a6de9dca25d8e0d390796a79267 (diff)
downloadpyramid-e3349693c533c17fb9b6a770a8360b64ec337c68.tar.gz
pyramid-e3349693c533c17fb9b6a770a8360b64ec337c68.tar.bz2
pyramid-e3349693c533c17fb9b6a770a8360b64ec337c68.zip
make less confusing
-rw-r--r--docs/narr/webob.rst11
1 files changed, 5 insertions, 6 deletions
diff --git a/docs/narr/webob.rst b/docs/narr/webob.rst
index 373ae5896..beb319084 100644
--- a/docs/narr/webob.rst
+++ b/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:
jQuery.ajax({type:'POST',
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: