通过PHP验证来纠正AJAX操作的MVC流程

As an example of what I am trying to ask, let's say that the user wants to delete an address from their account.

My workflow for my AJAX actions are basically:

  1. User clicks submit and the id of the stored address is sent to the controller
  2. The controller makes sure the user can perform the action (each user has different permissions)
  3. The controller makes sure that the id of the address given was attached to their account
  4. Any errors that were encounters are sent back and displayed to the user or the address was deleted and a success message is shown.

I am really having a hard time wrapping my head around what the proper MVC execution path for this would be. Can anybody help me out?

Actually, it should be something like:

  1. User clicks submit and the id of the stored address is sent to the controller
  2. The controller makes sure the user can perform the action (each user has different permissions)
  3. The controller queries the Model layer to associate the ID of the address given with the user's account.
  4. The controller invokes a View, which in turn invokes a template (since this is AJAX, it'll probably be a JSON template) which returns whatever state to the user (error, success). If you want to get really fancy, send a proper response code header as well.
  5. Client gets JSON response from AJAX and takes proper action.