Ajax Request Returns Html Response

I have come across this question before but I haven’t found a helpful answer whatsoever. What I want to know is why an ajax call to a codeigniter controller is returning an HTML response even when the controller function is not returning nothing explicitly.

So I have the following jquery ajax code:


$('#lgaStateField').change(function(){
var state = $(this).val();
            
if(state != 0){
    $('#lgaField').attr('disabled', false);
    $(processOngoing).css('display', 'block');

    $.ajax({
    url: "<?=base_url('adverts-report/fetch-lgas')?>",
    type: 'post',
    data: {stateId : state},
    success: function(r){
            //console.log(r);return false;
       // const resLgas = JSON.parse(r);
      // $('#lgaField').empty().append('<option value="0">Select Lga</option>');

     // for(var i = 0; i < resLgas.length; i++){
        $('#lgaField').append('<option value="' + resLgas[i].id + '">' + resLgas[i].name + '</option>');
    // }

    $(processOngoing).css('display','none');
    },
    error: function(err){
            console.log(err);
        $(processOngoing).css('display','none');
    }
      })
    }
})

And the following is a snippet of the endpoint that supposed to return a response but is currently empty:

public function fetch_lgas(){
        
    }

Yet when i check the Network section of my developer tab, there is an html response that is more or less the content of the current view.