0

Ajax 成功データの出力に問題があります。

success: function(data){
    alert(need to print it here);
}

アクセスしたときの様子

console.log(data.responseText);
{"success":false,"errors":{"text":["Some text.","some more text"]}}

「Some text」または「some more text」を今すぐアラートするにはどうすればよいですか? ありがとう

4

3 に答える 3

1

次のような結果を出力する div があるとします。

<div id="res_div"></div>

でコンテンツにアクセスできます。

console.log(data.responseText.errors.text);

次のことを試して、コンテンツをその div に出力するだけです

$("#res_div").text(data.responseText.errors.text);
于 2013-11-08T18:22:01.923 に答える
1

data次のように、オブジェクトを配列にドリルダウンして、errors.textそれらをループするだけです。

$.each(data.responseText.errors.text, function(index, item) {
    alert(item);   
});
于 2013-11-08T18:22:34.063 に答える