Not sure if I had opened my thread in the correct sub-forum, but was wondering if anyone from here can be of any help to me in http://www.sitepoint.com/forums/showthread.php?t=659639.
Apologies in advance if we’re not supposed to be opening new threads that link to others.
Objects do not exist anywhere outside the program.
You can interchange scalar values only.
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.
If I’m well off, I’d appreciate someone enlightening me