doulai8128 2013-12-16 17:06
浏览 50

通过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?

  • 写回答

1条回答 默认 最新

  • dsf23223 2013-12-16 17:13
    关注

    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.
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?