hy , excuse me i dont speak english very good :)
i created a dependble dropdown but i have erro in alert($.parsejson(data) return null controller action : $this->view->disable(); $response = new \Phalcon\Http\Response(); $request = new Phalcon\Http\Request(); $id_essai= $request->get('id_essai'); $query = "SELECT * FROM modalite WHERE modalite.id_essai = $id_essai"; $result_dis = $this->modelsManager->executeQuery($query); // var_dump($result_dis); //return json_encode($result_dis); return json_encode($result_dis, true);
function ajax in my view is : <script> $("#id_essai").change(function() { var value = $(this +'option:selected').val(); var getResultsUrl = '/STC4/prod/Query/moda'; $.ajax({ type: "GET", url: getResultsUrl, datatype: "json", data: {'id_essai': value}, success: function(data){ data = $.parseJSON(data); alert(JSON.stringify(data, undefined, 2)); alert($.parseJSON(data)); =======> return null for(var i=0 ; i<data.lenght; i++){ console.log(data[i]); var chaine =''; for(var i = 0 ; i<data.lenght; i++){ chaine += '<option value="'+ data[i].id_mod +'">'+ data[i].code_mod +'</option>'; } $('#id_mod').html(chaine); } } }); }); </script> please if you have any idea in this subject help me
thanks