Sorry i see that right here is heap of comparable questions, however i will probably be dare to ask the identical.
I am sending javascript two dimensional array to PHP script after which it saved to database. I am utilizing JSON.stringify and have such string within the database
[[“babaguliala”,”979485″,”xlopa kupa 12″],[“didoboroda”,”222455″,”nemadoma 12″]]
However when i attempt to retrieve this array and parse it i bought an error.
That is a part of PHP fubction that sends array to javascript:
$organizations = get_user_meta($current_user_id, 'organizations');
echo $organizations;
However when i attempt to parse this information i am getting error:
console.log( 'response: ' + response ); // response: Array
organizations =JSON.parse(response); // Error
Error element is right here:
Uncaught SyntaxError: Sudden token A in JSON at place 0
at JSON.parse (<nameless>)
at Object.success ((індекс):562:24)
at c (jquery.min.js?ver=3.6.0:2:28327)
at Object.fireWith [as resolveWith] (jquery.min.js?ver=3.6.0:2:29072)
at l (jquery.min.js?ver=3.6.0:2:79901)
at XMLHttpRequest.<nameless> (jquery.min.js?ver=3.6.0:2:82355)
However when it attempt thiscode enter into console:
const ajaxResponse="[["babaguliala","979485","xlopa kupa 12"],["didoboroda","222455","nemadoma 12"]]"
const arr = JSON.parse(ajaxResponse)
I am getting good response and parsing went proper.
arr[0] // ["babaguliala", "979485", "xlopa kupa 12"] (3)
arr[1] // ["didoboroda", "222455", "nemadoma 12"] (3)
Sorry however i don’t perceive what this behaviour imply. Might somebody clarify ?