I create this output with PHP:
foreach ($bk as $blink) {
$out[“url”][] = $blink->url;
$out[“anchor”][] = $blink->anchor;
}$json = Zend_Json::encode($out);
echo ($json);
I want to receive and process the output with a $.ajax call.
Could you point me to a nice tutorial about multidimensional arrays with javascript/jquery or help me loop* through the json results? I got a bit confused with it.
- I am trying to put those on a table, so I will be using
<td>url-i</td><td>anchor-i</td>. This part, I figured out how. To put the correct values onurl-iandanchor-iis the problem.
I would imagine the JSON output for that will be something like:
If that is the case, then they will be of equal length (and importantly equal indexes) and you can loop through one of the two using jQuery.each().
I’ve not run that code, so it might have a few flaws, but that’s the gist of it.