My AJAX result is
["1","O"]
I'm trying to access 1, but
console.log(result[0]);
gives me
'['
How can I make it as an object and get just the first element of my array result?
My AJAX result is
["1","O"]
I'm trying to access 1, but
console.log(result[0]);
gives me
'['
How can I make it as an object and get just the first element of my array result?
It looks like you are indexing into the string of your result. Try
var resultObj = JSON.parse(result);
console.log(resultsObj[0]);
What you're accessing is the string of the result. You need to parse it out of JSON format.
result = JSON.parse(result);