How do I access the data stored in JSON that is returned in the complete function of a JQuery AJAX request. For example, I have the following code:
$.ajax({
url: 'buildings.php',
data: "building=" + building,
complete: function (response) {
alert(response.responseText);
alert(response.name);
}
});
In the first alert it displays the following, which is the intended JSON data that I sent from PHP.
{"name":"HSB","description":"description","directionsURL":"directionsURL","imageArray":{"1":"URL 1","2":"URL 2"}}
In the second alert, it displays
undefined
How do I access the data I received that is displayed in the first alert?