ajax - Get the value of hidden input in the for with jquery -
hello guys (sorry english)
i work symfony 2 , i' meet difficulty jquery, explain:
i value of hidden input when mouse on item when doing :
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> $(function(){ $(".item").each(function(){ $(this).mouseover(function(){ var value = $(".id_sous_item").val(); var data = { id: value }; console.log(data); $.ajax({ url: "{{ path('sous_item_page') }}", cache: false, data: data, success: function(msg){ $(".item_right .description").append(msg); } }) }); }); }); </script>
{% emploi in list_emploi %} <p class="item"> {{ emploi.namesousitem }} </p> <input type="hidden" class="id_sous_item" value="{{ emploi.id }}"/> <hr/> {% endfor %}
the value first hidden input , how can each value of item ?
thanks friends :)
edit
thanks amit soni answer correct :)
now data passed ajax in controller make request, $data = $request->request->get('id_item'); null .
public function getdescriptionaction(request $request) { $data = $request->request->get('id_item'); $repository = $this ->getdoctrine() ->getmanager() ->getrepository('adminbundle:sousitem') ; $description = $repository->findby( array('id' => $data) ); return $description; }
get http://local.dev/symfony_ml/web/app_dev.php/categorie/?id_item=1&_=1427889521422 500 (internal server error)
i want first parameters have idea ?
Comments
Post a Comment