javascript - POST http://localhost:8080/create 500 (Internal Server Error)5

I always get "POST http://localhost:8080/create 500 (Internal Server Error)" when insert new data in ajax (CodeIgniter 4, Bootstrap 5). I've checked and replaced JQuery many times, and don't know what's wrong with my code. This is my javascript code (action.js) :

$(document).ready(function() {
    $("#save").on('submit',function(e){  
        e.preventDefault();
        const nama=$("#nama_id").val();
        const image=$("#file_id").val();
        const formdata=new FormData(this);
        if(nama == "" || image == "" ){  
            alert("Nama dan foto harus diisi");
        }
        else{  
            $.ajax({ 
                url:"/create",
                type:"POST",
                data:formdata,
                processData:false,
                contentType:false,
                success:(data)=>{
                    if(data == 1){  
                        alert("Tambah data sukses");
                    }else{  
                        alert("Tambah data gagal");
                    }
                }
            })
        }
    });

and this is the function inside controller code :

   public function simpan() {         
        $cv = $this->cvModel->getCV();
        $fileName = $this->request->getFile('file');
        if ($fileName->isValid() && ! $fileName->hasMoved()) {
            $newName = $fileName->getRandomName();
            $fileName->move("uploads/", $newName);
        }       
        $data = [
            'nama' => $cv->request->getVar('nama'),
            'pasfoto' => $newName,
        ];
        
        $simpan = $cv->save($data);
        if ($simpan) {
            echo 1;
        }else {
            echo 0;
        }
    }

When I inspect in Chrome it always stuck in row 27 (start ajax) like this : enter image description here

Answer

Solution:

you can try

url : base_url().'/class_name/methode_name';

Source