summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-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: