jquery - Parse nested json into ajax -
i have sample json structured as,
{ key : { "data1":data1, "data2":data2 }}
i want parsed 'data',
$.ajax({ type: 'post', url: 'url', data: <--- here , success: function() { ***** } });
how do it?
try use json.stringify
var data= { "key" : {"data1":"data1", "data2":"data2" }}; new request.json({ url: '/echo/json/', type: "post", data: json.stringify(data), contenttype: "application/json", onsuccess: function(res) { document.write(data.key.data1); console.log(data.key.data1); } }).send();
here working jsfiddle: http://jsfiddle.net/dk5dl/87/
Comments
Post a Comment