I have an API call that I'm using to get data. This data is an array of arrays and I need to loop through them. For each value, I want to 'load' a php template I created with those values. The very first loop works and displays properly, but after the initial value, it stops. I need all values to be looped through and displated.
Example of what is happening: [a, b, c] => JQuery loop => load => Only 'a' shows up.
EDIT - Every time load is called, it loads the script into 'elementToLoadPhpFile'. I noticed that it seems to be overwriting the previous values that are loaded there. I need it to append multiple children, not override the same child.
$.ajax({
type: 'GET',
dataType: "json",
url: 'apiUrl.com'
}).done(function(data) {
var result = data['data'];
jQuery.each(result, function(key, value) {
var id = value['id'];
var title = value['title'];
var img_url = value['images']['jpg']['image_url']
$("#elementToLoadPhpFile").load("phpFile.php", {
id: id,
title: title,
img_url: img_url
});
});
});
your HTML here.
');` work the same as jQuery `.append('your HTML here.
');`. – vee Apr 03 '22 at 03:33