jQuery JSon is not parsed
I am trying to parse received JSON object but obj is always null and obj.d is undefined. Where is the problem?
JSon response
{"d":"psize=a4&porient=portrait&margintop=10&marginleft=5&marginright=5&marginbottom=10&title=&author=&subject=&keywords=&userpass=&ownerpass=&coverpage=http%3A%2F%2F&conversiondelay=1&allowscript=true"}
The code which call server and receive response above from server
$.ajax({
type: "POST",
url: "Default.aspx/LoadOptions",
data: "",
contentType: "ap开发者_Go百科plication/json; charset=utf-8",
dataType: "json",
success: function (data) {
var obj = $.parseJSON(data);
console.log(obj.d);
},
error: ""
});
You don't need $.parseJSON
if your dataType is json
.
data
is the javascript object itself.
精彩评论