我没有获取ajax的网址

I am working on categories and its subcategories when in my code I am getting id from category but it is not able to pass into Ajax and its URL. My code is

<script type="text/javascript">


    $(document).ready(function() {
        $('select[name="category"]').on('change', function() {
            var stateID = $(this).val();
            if(stateID) {
                $.ajax({
                    url: "<?php echo base_url("myformAjax");?>/"+stateID,
//                    alert(url);
                    type: "GET",
                    dataType: "json",
                    success:function(data) {
                        $('select[name="subcategory"]').empty();
                        $.each(data, function(key, value) {
                            $('select[name="subcategory"]').append('<option value="'+ value.id +'">'+ value.subcategory +'</option>');
                        });
                    }
                });
            }else{
                $('select[name="subcategory"]').empty();
            }
        });
    });
</script>

you have a mistake in your code.

you are using double-quotes inside double-quotes

change this line

 url: "<?php echo base_url("myformAjax");?>/"+stateID,

to

 url: "<?php echo base_url('myformAjax');?>/"+stateID,

updated answer:

assign the php value to js variable and concat both.

var phpVal = <?php echo base_url('myformAjax');?>;

and then

url: phpVal + "/" + stateID,