I have a json value converted from array in ajax response.
{"Text":"Please provide a value","Email":"Please provide a value"}
I need the response json to be extracted in a div using $(div).html():
Text-Please provide a value
Email-Please provide a value
I tried it using $.each():
var json=JSON.stringify({"Text":"Please provide a value","Email":"Please provide a value"});
var arr = [];
var obj = jQuery.parseJSON(json);
$.each(json,function(key,value)
{
arr.push('<li>'+value+'</li>');
});
var arrval =arr.join('');
console.log(arrval);
But I got output as undefined. I know there is some logical mistake I have done while extracting? What have I done wrong in here??
Note: The array key value pair in json can be dynamic ie., it may be one, two or more..
$.each(obj, ...)instead of$.each(json, ...).