I've been trying to figure this out for what seems like forever. My PHP is working fine. As an example, it returns the following if I select "Grove Bow" from my select dropdown:
[{"wtype":"Grove Bow","was":"1.55","wcc":"5","wbdmin":"12","wbdmax":"37"}]
The issue is in parsing the data in the success callback function in my .js file where I have written:
$.post("get.php",
{w:wname},
function(data) {
was = data[1].was;
wcc = data[2].wcc;
wbdmin = data[3].wbdmin;
wbdmax = data[4].wbdmax;
console.log($.parseJSON(data));
}
);
The console returns what I believe to be an empty array:
[Object]
0: Object
length: 1
__proto__: Array[0]
If I remove the $.parseJSON() the console returns the same result that was posted by my get.php file:
[{"wtype":"Grove Bow","was":"1.55","wcc":"5","wbdmin":"12","wbdmax":"37"}]
I need to access these elements of the array as you can see by my attempt to store them as variables (don't worry, I declared them earlier at the top of my .js file).
Pliss halp!
}, 'json');to have the data returned automatically parsed as json.