有人可以帮我在jQuery中读取这个回调数组吗?
{
"message-count":1,
"error-text": "Invalid Phone format. Please ensure phone number to be in international format. e.g 447876567655."
}
答案 0 :(得分:4)
您可以使用JSON.parse()
和$.each()
var a=JSON.parse('{ "message-count":1, "error-text":"Invalid Phone format. Please ensusure phone number to be in international format. e.g 447876567655 ." } ');
$.each(a,function(i,v){
console.log(i+':'+v);
})
答案 1 :(得分:3)
你的是JSON回复,只需使用Bracket notation
var data = { "message-count":1, "error-text":"Invalid Phone format. Please ensusure phone number to be in international format. e.g 447876567655 ." };
alert(data['message-count']);