I have the following data response from an ajax return:
{"status":"success","message":[{
"ID":103642,
"Date":"2016-04-18 00:00:00.000",
"Testimonial":"First I would like to thank you.\n",
"FirstName":"Joe",
"LastName":"Phillips",
"Title":"","Company":"International Minute Press",
"City":"Raleigh",
"State":"NC",
"Rating":"5"},
{"ID":102652,
"Date":"2016-04-12 09:04:08.000",
"Testimonial":
"All of the staff were professional and courteous. ",
"FirstName":"Mike",
"LastName":"",
"Title":"",
"Company":"City of Longview",
"City":"Longview",
"State":"TX","Rating":"5"},
{"ID":102546,
"Date":"2016-04-12 08:26:52.000",
"Testimonial":"The design group is great. ",
"FirstName":"Jammie",
"LastName":"",
"Title":"",
"Company":"TACLE Seating USA, LLC",
"City":"Mount Juliet","State":"TN",
"Rating":"5"},
{"ID":102547,
"Date":"2016-04-12 05:17:41.000",
"Testimonial":"I have only a few specific orders with the company",
"FirstName":"Larry",
"LastName":"",
"Title":"",
"Company":"Accent Label & Tag",
"City":"Ronkonkoma",
"State":"NY",
"Rating":"5"
}]}
I would like to be able to create a “Previous” and “Next” button to iterate through the json array/object. I have tried several things with no luck…
here is the ajax:
$(document).ready(function () {
$.ajax({
url: 'php/getTestimonials.php',
type: 'get',
//dataType: 'json',
success: function(data) {
//alert(data);
$("#res_div").html(data);
}
});
});
I have this in the php file to access the json data after it is decoded from above:
$test_0 = "<p>“" . $json_output['message'][0]['Testimonial'] . "”</p><p class='authornew'>" . $json_output['message'][0]['FirstName'] . " - " . $json_output['message'][0]['City'] . ", " . $json_output['message'][0]['State'] . "</p>";
$test_1 = "<p>“" . $json_output['message'][1]['Testimonial'] . "”</p><p class='authornew'>" . $json_output['message'][1]['FirstName'] . " - " . $json_output['message'][1]['City'] . ", " . $json_output['message'][1]['State'] . "</p>";
$test_2 = "<p>“" . $json_output['message'][2]['Testimonial'] . "”</p><p class='authornew'>" . $json_output['message'][2]['FirstName'] . " - " . $json_output['message'][2]['City'] . ", " . $json_output['message'][2]['State'] . "</p>";
$test_3 = "<p>“" . $json_output['message'][3]['Testimonial'] . "”</p><p class='authornew'>" . $json_output['message'][3]['FirstName'] . " - " . $json_output['message'][3]['City'] . ", " . $json_output['message'][3]['State'] . "</p>";
Any help would be greatly appreciated.
Thanks!