Skip to content
Advertisement

Convert PHP array from AJAX response to Javascript Object

I’m trying to create a JavaScript object based on a template I received as a test. I use Ajax to get the data from my database but i cant seem to create the object.

JavaScript

I’m trying to create something like this object below

JavaScript

This is the how i fetch the data from my database

JavaScript

Advertisement

Answer

Your lines with products[x] overwrite the earlier.

Change to

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement