jQuery.load() with object parameter to Pyramid causes “No JSON object could be decoded”

A simple call like this:

type = 'theType';
category = 'theCategory';
$('#mydiv').load(
  '${request.route_url('theUrl')}',
  {type:type, category:category}
);

results in a "No JSON object could be decoded" error when I try to access the request.json_body object. Looking at the request, I can see that it is a POST, X-Requested-With: XMLHttpRequest, and that the body is type=theType&category=theCategory, which certainly isn't JSON.

What am I doing wrong?

I'm using Pyramid 1.3, Mako 0.72, jQuery 1.7.2

Answers


jQuery.load() does not send JSON. In pyramid, simply access the form variables like you would with a normal POST request:

request.params['type']

etc.


Need Your Help

NLog via LINQPad - Where to put config file?

c# .net nlog linqpad

I'm trying to test NLog under LINQPad.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.