Link to home
Start Free TrialLog in
Avatar of antum
antum

asked on

PHP to return an array to SAJAX, having trouble

Hi,
I have sajax working, im new to it.

I have a PHP function:

function get_table2_data(){
      return array('achievements', 'second');

}

then my javascript function that handles the data does this:

function do_table2_update_cb(table_arr) {
      alert(table_arr[0]);
      for (j = 0; j < table_arr.length; j++)
      {
              var table2_el = document.getElementById('table2');
              table2_el.options[table2_el.options.length] = new Option(table_arr[j], table_arr[j]);
      }
}

and that first alert is just showing 'A' as if table_arr is just a string with a value of 'Array'

Any ideas how to get PHP to return a javascript array

Thanks
Ant
ASKER CERTIFIED SOLUTION
Avatar of malaiac
malaiac

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial