I am trying to display the result of my php in different <div>-s. My plan is that I make a request in my php and display the result in JSON format. Due to the JSON format, my result may appear different <div>. How can I achieve this, for example, "name"can be displayed between tags <div>?
Example php result:
[
{
"id": 0,
"name": "example1",
"title": "example2"
},
{
"id": 0,
"name": "example1",
"title": "example2"
}
]
Attempt:
<div class="result"></div>
<script>
$.ajax({
type:'GET',
url:'foo.php',
data:'json',
success: function(data){
$('.result').html(data);
}
});
</script>
source
share