I am using jquery $ .post to dynamically retrieve information from a database. This works fine if I need one element, I would like to save each column as an array and pass the entire array. I have an array, but I have problems returning it to javascript, so I can use it.
Since the array will contain text with commas, I cannot use implode to create a comma separated string.
Try using json, if you use php json_encode in a server-side array, then the echo of the jquery encoded array will perceive it as a json object.
"json" :
$.post("/your/page", dict, function(data) { dosomething(); }, "json");
.each
jQuery.each(data, function(i, val) { alert(i); alert(val); });
:
data['key']
. , , , /your/page, JSON ( PHP . json_encode)
Source: https://habr.com/ru/post/1762391/More articles:PHP: using a shorter tag will not work - phpSecure write from mongodb shell - mongodbInstall JRebel in Rational SW Architect (Eclipse) - eclipseHow to decode Get / Post Request headers in tuples using Cherry Py? - pythonCalling / monitoring JVM via JMX from a client without java - jvmImplements open source projects with best practices and / or code standards? - ruby | fooobar.comWhy jQuery Form Plugin mixes NULL and 0 - jqueryHow to correctly determine the width of an attribute string - objective-chow to read (default) value in registry key in VBScript / JScript - wshСтрока PHP в массиве возвращает только первый символ - phpAll Articles