I cannot post data. The response is 404 and the url response is undefined
.
Here is my code:
//model
public function lihat_nama_method($nama_fgwtmethod) {
$query = $this->db->select('*');
$query = $this->db->where(['nama_fgwtmethod' => $nama_fgwtmethod]);
$query = $this->db->get($this->_table);
return $query->row();
}
//Controller
public function get_all_method(){
$data = $this->m_fgwttesting->lihat_nama_method($_POST['nama_fgwtmethod']);
echo json_encode($data);
}
<script>
$("#id_fgwtmethod").on("change", function(){
if($(this).val() == '') reset()
else {
const url_get_all_method = $("#content").data("url") + "/get_all_method"
$.ajax({
url: url_get_all_method ,
type:'POST',
dataType: 'json',
data: {id_fgwtmethod: $(this).val()},
success: function(data) {
$('select[name="id_fgwtmethod"]').val(data.id_fgwtmethod)
$('button#tambah').prop('disabled', false)
}
})
}
})
</script>
The result of code above: