こんにちは、私は JSON を持っています:
[{"id":"1","message":"sdvsvdsdv","nickname":""},{"id":"2","message":"1234556","nickname":""},{"id":"3","message":"4555555","nickname":""}]
JavaScript 関数:
function ajax_request(){
var request = new XMLHttpRequest();
var url = "http://localhost/chat/controller.php?showmessage";
request.open("post", url, true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.onreadystatechange = function(){
if(request.readyState == 4 && request.status == 200){
var return_data = request.responseText; // THE WHOLE JSON
document.getElementById("chat").innerHTML = return_data;
}
}
request.send();}
JSON全体ではなく、要素「メッセージ」のみを取得するにはどうすればよいですか?.