I found this and its very helpful...
Demo: jQuery Ajax Call to PHP Script with JSON Return
But i have some problem with to use it....
I need to understand how to use it correctly...
I dont understand why my array cannot be transform in a json....
These code are in response.php :
$champs = ["user" => "", "combinaison" => 0, "valeurSmall" => "", "valeurBig" => "", "aucune_valeur" => false, "trop_valeur" => false, "color_red" => 0, "color_green" => 0, "color_blue" => 0];
$return["json"] = json_encode($champs, JSON_FORCE_OBJECT);
echo json_encode($return);
And in my index.html the part javascript :
$.ajax({
type: "POST",
dataType: "json",
url: "changerMise/changer.php",
data: data,
success: function(dataReturn) {
alert("Form submitted successfully.\nReturned json: " + dataReturn["json"] );
}
});
The alert dont come back with the thing i need to use after....
The result gave :
Form submitted successfully.
Returned json: {"aucune_valeur": true}
any ideas ?!??!
Thx guys
echo json_encode($champs,JSON_FORCE_OBJECT);...