brython-dev/brython — pull request #50 by joaoventura (2014-10-29 18:03:07+00:00)
Title: Fix ajax string argument

The ajax.send function fails every time it is called with a string
parameter. This happens because the ‘send’ javascript function tests
for ‘params.$keys.length==0’ before checking if it is a string, and
strings don’t have ‘$keys’.

This change fixes the problem, and continues to work for the empty
dictionary case (when $keys.length==0) which is perfectly handled by
the ‘for’ loop over the length of keys.

(By the way, I spot this error while doing 'req.send(json.dumps(data))', i.e., sending JSON data to the server as string. It now works perfectly!)