Hi everyone,
I’m trying to pass js obects to php via jQuery’s .load() function.
Everything is working fine but I don’t know or understand how to output the obect using php.
Here is my JS code:
jQuery(function () {
var myArray = [{ 'name' : 'Steve', 'surname' : 'Bluck' }];
//Save options via Ajax-------------//
jQuery("#saveoptions").click(function(){
jQuery(this).load('<?php bloginfo('template_directory'); ?>/lib/admin/save.php', {
'options[]' : myArray
});
});
});
This is my PHP code:
$options = $_POST['options']; print_r($options);
And the outcome is this:
Array ( [0] => [object Object] )
What am I doing wrong?
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 3-4 years
Maybe you should check out the PHP functions json_encode and json_decode?
Edit: I was looking for a tut that handles AJAX interaction with PHP with the avove mentioned functions but I can’t find it anymore.
If you’re still having difficulties I can send you my js and php script that does this kind of interaction, let me know
I think the scripts are pretty self-explanatory.
Maybe you should check out the PHP functions json_encode and json_decode?Edit: I was looking for a tut that handles AJAX interaction with PHP with the avove mentioned functions but I can’t find it anymore.
If you’re still having difficulties I can send you my js and php script that does this kind of interaction, let me knowI think the scripts are pretty self-explanatory.
Yes please, I’m going crazy – I’ll send you a mail now.
