1 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
2
3 <script type="text/javascript">
4 $(document).ready(function () {
5 $(document).on('change','.productCategory',function () {
6 // console.log('hmm its change')
7 var sub_cat=$('select[name="sub_cat_id"]')
8 var category_id=$(this).val();
9 // console.log(category_id);
10 var div=$(this).parent();
11
12 // var op=" ";
13
14 $.ajax({
15 type:'get',
16 url:'{!!URL::to('findsubcategory')!!}',
17 data:{'id':category_id},
18 success:function (data) {
19 // console.log('success');
20 //
21 // console.log(data);
22 // console.log(data.length);
23
24 var op= `<option disabled="true" selected="true">---Select Sub category---</option>`;
25
26 for (var i=0;i<data.length;i++) {
27 op += '<option value="' + data[i].id + '">' + data[i].sub_cat_name + '</option>';
28
29 }
30
31 sub_cat.html(op);
32
33 },
34 error:function () {
35
36 }
37 });
38 });
39 });
40 </script>