how to manipulate Json response like an object?
ajax, jquery, json
Solution
The value of item is a string. Thus you first need to parse it as json. Try this.
$("#jsonResponse").html(msg);
var item = jQuery.parseJSON(msg.item)
$.each(item, function(i, d) {
alert(this.country);
debugger;
});
},
Problem
my jQuery.ajax return JSon object. I firstly read other articles. but their response text not likes mine. My Response content: from firebug response ``` {"item":"[{\"country\":\"USA\",\"lan\":\"EN\"},{\"country\":\"Turkiye\",\"lan\":\"TR\"}]"} ``` Now i trying to alert countryName: ``` $('#loadData').click(function() { $.ajax({ type: "POST", url: "WS/myWS.asmx/getDaa", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { $("#jsonResponse").html(msg); $.each(msg.item, function(i, d) { alert(this.country); debugger; }); }, }); }); ``` but it is alerting "undefined"