I\'ve been using Serialize() to pass checkbox form data with Post() for a basket that can hold multiple items of the same category.
When I post them using the submit
I did not find any good solution, so i solved this using JSON.stringify(); here is my code
Client side :
var data = {a:{'foo':'bar'},b:{'this':'that'}};
$.ajax({ url : '/',
type : 'POST',
data : {'data':JSON.stringify(data)},
success : function(){ }
});
Server Side:
$data = json_decode($_POST['data']);
print_r($data);
// Result:
// Array( "a" => Array("foo"=> "bar"), "b" => Array("that" => "this"))