Returning an array from a PHP function to jQuery

ajax, jquery, php

Solution

Use json_encode() to turn your PHP array into a native JavaScript array, then use jQuery $.post, $.get, or $.ajax methods to fetch this value from your PHP script. I generally use $.post unless I need the special features that $.ajax provides.

Problem

I have a PHP function that returns an array. What is the best way to "receive" this using jQuery?

Original source