我已经看到了将数组转换为json但不是纯变量的示例。我是json的新手,需要一个可以打印出类似内容的ajax / javascript函数:
{"name":["1"],"email":["1"],"phone":["1"],"subject":["1"],"message":["1"]}
答案 0 :(得分:0)
我创建了一个jsfiddle.net,向您展示如何执行此操作:
javascript是这样的:
var data = {
"name": ["1"],
"email": ["1"],
"phone": ["1"],
"subject": ["1"],
"message": ["1"]
}
$.each(data, function(key, value) {
$('#test').append(key + ": " + value + "<br />");
});
输出:
name: 1
email: 1
phone: 1
subject: 1
message: 1