codeigniter HMVC ajax更新功能

i have this ajax function i found in an opensource code.

function edit_person(id)
{
  save_method = 'update';
  $('#form')[0].reset(); // reset form on modals

  //Ajax Load data from ajax
  $.ajax({
    url : "<?php echo site_url('person/ajax_edit/')?>/" + id,
    type: "GET",
    dataType: "JSON",
    success: function(data)
    {

        $('[name="id"]').val(data.id);
        $('[name="firstName"]').val(data.firstName);
        $('[name="lastName"]').val(data.lastName);
        $('[name="gender"]').val(data.gender);
        $('[name="address"]').val(data.address);
        $('[name="dob"]').val(data.dob);

        $('#modal_form').modal('show'); // show bootstrap modal when complete loaded
        $('.modal-title').text('Edit Person'); // Set title to Bootstrap modal title

    },
    error: function (jqXHR, textStatus, errorThrown)
    {
        alert('Error get data from ajax');
    }
});
}

it does open a form over the data table with the information to be updated..

to briefly explain what i want to happen,

i have this folders in my module

folder
--controller
--model
--views
----main.php
----edit.php
----add.php

what i want to do is when i click the button, ajax will get the values i need to update and go to my edit.php and show the values there

No you can't call edip.php from VIEWS folder with AJAX request. Create a class called Person with edit_ajax method. And send your information from Ajax to edit_ajax method.

folder
--controller
----person.php  /*Person class, contains edit_ajax method*/
--model
----person.php  /*Contains update_person method, Call it from edit_ajax,
                  this model method will update Database with new information*/
--views  
----main.php
----edit.php
----add.php