I’ve done some research and noticed that JSON might actually be what I’m looking for. However, I’ve been having some problems to get my code to work.
I’ve got the following code that creates an object and then encodes it to be represented in the JSON format:
$a = new Admin_Template();
$js = json_encode( $a );
I have a button that has an onclick event that calls a JS function ‘test()’.
My problem is I’m not sure how I can use the $js variable in that function (if it can be done at all). I know embedding PHP within JS doesn’t work due to their client/server differences, and so was wondering what are the series of steps I need to follow in order to make use of the content of the js variable within JS.