I've seen examples of getting arrays made into json but not pure variables. I'm new to json and need a ajax /javascript function that can print out the contents of something like this:
{"name":["1"],"email":["1"],"phone":["1"],"subject":["1"],"message":["1"]}
I created a jsfiddle.net that shows you how you could do this:
The javascript is this:
var data = {
"name": ["1"],
"email": ["1"],
"phone": ["1"],
"subject": ["1"],
"message": ["1"]
}
$.each(data, function(key, value) {
$('#test').append(key + ": " + value + "<br />");
});
which outputs:
name: 1
email: 1
phone: 1
subject: 1
message: 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.