Jump to content

convert json array to variables

- - - - -

  • Please log in to reply
No replies to this topic

#1
Demodog

Demodog

    Newbie

  • Members
  • Pip
  • 9 posts
Hi!

In an ajax call, how do I in the most simpliest way convert php array variables from:

$arr = array ('name'=>'John','adress'=>'greenroad 2');
echo json_encode($arr);

into javascript variables:

var name
var adress

I want to be able to print them out in seperate DIVs by using:
document.getElementById('namediv').innerHTML = name;




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users