php - Get values after ajax request in json -
i have problem json after ajax request. when user click on submit button, ajax request looks if values correct. want return wrong field in json format , after in callback function. don't know how do.
this call ajax :
<script type="text/javascript"> $(document).ready(function(){ $('#submit_button_essai').click(function(){ $("td").eq(2).css("background-color","red"); $.post("ajax_insert_essai.php",{arr:data_essai}, insert_essai_callback); }); }); </script>
and here ajax :
$array = $_post["arr"]; $json = json_encode($array); $tab_erreur=array(); foreach($array $ligne)//boucle de parcours du tableau envoyé (hot) { foreach ($xml $table) { // boucle de parcours de chaque élément <table> (xml) foreach ($table $champs) { // boucle de parcours de chaque noeud <champs> de l'élément <table> (xml) if ($table['nom']=='analyse') // si on se trouve dans la table correspondante (xml) { if ($champs->nom==$ligne[0]) //si le champs xml est égal au champs hot { if(($champs->type_entree=='obligatoire') && ($ligne[1]=='')) //si l'entrée est obligatoire et qu'il n'y pas de saisie { $flag = false; array_push($tab_erreur,$ligne[0]); } } } } } } return json_encode($tab_erreur);
and callback function :
function insert_essai_callback(responseobject,ioargs) { var jsonobject = eval(responseobject ); console.log(jsonobject.id_analyse); }
i need me, please !
i don't know framework using, use
return json_encode($tab_erreur);
maybe should echo it. said - depends on php framework.
Comments
Post a Comment