Array
(
[infos] => address=&phone=&mail=
[products] => Product0=C&Product1=B&Product2=A&Produic3=C
)
Above is what I managed to get in php using this javascript:
var $products = $("#selectProducts").find("input");
var serializedProducts = $products.serialize();
request = $.ajax({
url: "backend.php",
type: "post",
data: {
infos: serializedData,
products: serializedProducts
}
});
I have tried unserialize(), but it sends an error. Also, [Product0]
, [Product1]
, etc are <input>
names and A
, B
, C
are <input>
values. I do not know how much of these <input>
will be sent to the php, it's up to the user.
And here's what I would like to get in Php (or as close to this as possible) :
Array
(
[infos] => address=&phone=&mail=
[products] => Array (
[Product0] => C
[Product1] => B
[Product2] => A
[Product3] => C
)
)
I just can't figure how to create the corresponding javascript object.