jQuery – How to PUT JSON via Ajax?

I think the data needs to be a String. Objects are converted to query strings which is what you are seeing here.

You can use the JSON.stringify(obj) method to convert your Object to a String. The code for the JSON object is available from: https://github.com/douglascrockford/JSON-js/blob/master/json2.js.

Alternately, just pass the code you are using to create the object as a literal String, but I imagine this is just an example and you’ll want to encode some object you’ve already created.

Leave a Comment