Reading Json Data in Jquery -
i have json data returning service.
here complete json data
d: "[{"imagepath":null,"themetemplateid":1,"borderwidth":null,"borderstyle":null,"optiontextunderline":null,"optiontextitalic":null,"optiontextbold":null,"optiontextsize":null,"optiontextfont":null,"questiontextunderline":null,"questiontextitalic":null,"questiontextbold":null,"questiontextsize":null,"questiontextfont":null,"surveytitleunderline":null,"surveytitleitalic":null,"surveytitlebold":null,"surveytitlesize":null,"surveytitlefont":null,"bordercolor":null,"surveytitlecolor":null,"optiontextcolor":null,"themename":null,"backgroundcolor":null,"questiontextcolor":null},{"imagepath":null,"themetemplateid":2,"borderwidth":null,"borderstyle":null,"optiontextunderline":null,"optiontextitalic":null,"optiontextbold":null,"optiontextsize":null,"optiontextfont":null,"questiontextunderline":null,"questiontextitalic":null,"questiontextbold":null,"questiontextsize":null,"questiontextfont":null,"surveytitleunderline":null,"surveytitleitalic":null,"surveytitlebold":null,"surveytitlesize":null,"surveytitlefont":null,"bordercolor":null,"surveytitlecolor":null,"optiontextcolor":null,"themename":null,"backgroundcolor":null,"questiontextcolor":null}]"
///ajax function
jquery.ajax({ type: "post", url: "3.aspx/getthemelist", data: "{'clientid':'" + -1 + "'}", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (returndata) { console.log(returndata); jquery.each(returndata, function (index, theme) { alert(theme.imagepath); alert(theme.themetemplateid); }); } });
but not working me there other method read data through jquery.
thanks help.
i think working http://jsfiddle.net/srsxa/2/...
but in post missed comma(,
) second json object
[{"imagepath":null,"themetemplateid":1},{"imagepath":null, "themetemplateid":2}] ^-- need comma here
according edit
d: "[{"ima.. ^--- don't need `"` here , @ last, don't need wrap `""`.
full working code:
var themelist = { d: [{ "imagepath": 'a', "themetemplateid": 1, "borderwidth": null, "borderstyle": null, "optiontextunderline": null, "optiontextitalic": null, "optiontextbold": null, "optiontextsize": null, "optiontextfont": null, "questiontextunderline": null, "questiontextitalic": null, "questiontextbold": null, "questiontextsize": null, "questiontextfont": null, "surveytitleunderline": null, "surveytitleitalic": null, "surveytitlebold": null, "surveytitlesize": null, "surveytitlefont": null, "bordercolor": null, "surveytitlecolor": null, "optiontextcolor": null, "themename": null, "backgroundcolor": null, "questiontextcolor": null}, { "imagepath": 'b', "themetemplateid": 2, "borderwidth": null, "borderstyle": null, "optiontextunderline": null, "optiontextitalic": null, "optiontextbold": null, "optiontextsize": null, "optiontextfont": null, "questiontextunderline": null, "questiontextitalic": null, "questiontextbold": null, "questiontextsize": null, "questiontextfont": null, "surveytitleunderline": null, "surveytitleitalic": null, "surveytitlebold": null, "surveytitlesize": null, "surveytitlefont": null, "bordercolor": null, "surveytitlecolor": null, "optiontextcolor": null, "themename": null, "backgroundcolor": null, "questiontextcolor": null}] }; $.each(themelist.d, function(index, theme) { console.log(theme['imagepath']); console.log(theme.imagepath); });
Comments
Post a Comment