Encode data before sending it through AJAX

Without this patch, ckan.js breaks with a JSON like:

```json
{
    "name & gender": "Sam & female"
}
```

Because the ampersand isn't escaped.