Wednesday, April 20, 2016
Convert and Loop through JSON with PHP and JavaScript Arrays/Objects
Posted by Duc Nguyen at 12:15 AM$("#gender").on("change", function() {
$.ajax({
type: "POST",
data: {
"gender": $("#gender").val()
},
url: "response.php",
dataType: "json",
success: function(JSONObject) {
var peopleHTML = "";
// Loop through Object and create peopleHTML
for (var key in JSONObject) {
if (JSONObject.hasOwnProperty(key)) {
peopleHTML += "
"
;
peopleHTML += "" + JSONObject[key]["name"] + "
";
peopleHTML += "
see more:
https://jonsuh.com/blog/convert-loop-through-json-php-javascript-arrays-objects/
0 Comments:
Subscribe to:
Post Comments (Atom)