久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

MVC ajax 調用 - 在哪里處理它們?

MVC ajax calls - where to handle them?(MVC ajax 調用 - 在哪里處理它們?)
本文介紹了MVC ajax 調用 - 在哪里處理它們?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個正在構建的自卷式 MVC 框架,到目前為止已經設法避免了對任何 AJAX 調用的需要.但是,現在我想創建一個實時更新的提要.

I have a self-rolled MVC framework that I am building, and up to this point have managed to avoid the need for any AJAX calls. Now, however, I'd like to create a real-time updating feed.

我的問題是,通常在 MVC 中存儲的 ajax 調用處理程序在哪里?我應該將它們存儲在參與調用的同一個控制器中嗎?

My question is, where are the handlers for the ajax calls usually stored in an MVC? Should I store them in the same controller that is involved in making the call?

例如,如果我的域 www.example.com/browse/blogs(browse 是控制器,blogs 是方法)正在對更新的博客列表進行 AJAX 調用,該調用是否只是對 www.example 的調用.com/browse/update_list 什么的?

For example, if my domain www.example.com/browse/blogs (browse is the controller, blogs is the method) is making an AJAX call for an updated list of blogs, would the call simply be to www.example.com/browse/update_list or something?

或者,它是一個單獨的 AJAX-only 控制器嗎?www.example.com/ajax/update_blogs

OR, so it be to a separate AJAX-only controller? www.example.com/ajax/update_blogs

你是怎么做到的?

推薦答案

我認為 Ajax 請求與非 Ajax 請求完全相同:實際上,從HTTP 協議.

I'd say an Ajax request is exactly the same as a non-Ajax one : it works exactly the same way, actually, from a point of view of HTTP Protocol.

唯一的區別是您返回的是一些非格式化數據,如 JSON 或 XML (嘿,這與生成 ATOM 提要 ^^ 相同),或者只是一個HTML 頁面.

The only difference is that you are returning some non-formated data, as JSON or XML (hey, this is the same as generating an ATOM feed ^^ ), or only a portion of an HTML page.

因此,我會將它們視為任何其他普通"HTTP 請求,并按照非 Ajax 請求的方式放置它們.

So, I would treat those as any other "normal" HTTP request, and place them the way I would for non-Ajax requests.


一種半替代的想法可能是在您的控制器中只有一個操作:/browse/blogs -- 并始終調用該操作.


A semi-alternate idea might be to have only one action in your controlller : /browse/blogs -- and always call that one.

但是,它會檢測它是否通過 Ajax 請求,并且會:

But, it would detect if it's being via an Ajax request or not, and would :

  • 如果通過正常"請求調用,則返回完整頁面
  • 或者如果通過 Ajax 請求調用,則只返回一些數據(或頁面的一部分)

注意:這不是一個瘋狂"的想法;例如,Zend Framework 提供了一些東西來促進這一點(參見 12.8.4.3. ContextSwitch 和 AjaxContext )

Note : that's not a "wild" idea ; Zend Framework, for instance, provides some stuff to facilitate that (see 12.8.4.3. ContextSwitch and AjaxContext )

這篇關于MVC ajax 調用 - 在哪里處理它們?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Action View Helper in Zend - Work around?(Zend 中的動作視圖助手 - 解決方法?)
Is this a good way to match URI to class/method in PHP for MVC(這是將 URI 與 PHP 中用于 MVC 的類/方法匹配的好方法嗎)
Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(視圖),以便我的應用程序中的所有視圖都可以訪問?) - IT屋-程序員軟件開發技術
Having a single entry point to a website. Bad? Good? Non-issue?(有一個網站的單一入口點.壞的?好的?沒問題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務層在 Zend 或 PHP 中常見嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
主站蜘蛛池模板: 狠狠草视频 | 久草日韩| 91av免费版 | 久久午夜视频 | 中文字幕在线观看一区二区 | 一级片在线播放 | 日本超碰 | 国产精品乱码一区二区三区 | 成人av播放 | 天天躁日日躁aaaa视频 | 日韩欧美亚洲 | 国产午夜av片 | 亚洲成人精品影院 | 成人美女免费网站视频 | 国产一区二区三区在线 | 亚洲精品黄色 | 国产婷婷精品av在线 | 欧美5区| 欧美日韩一区二区三区四区 | 日韩成人免费 | 国产成人免费视频网站视频社区 | 精品国产一区二区三区av片 | 97超碰成人| 日韩成人高清在线 | 成人毛片在线视频 | 亚洲精品视频在线观看视频 | 精品国产乱码久久久久久丨区2区 | 欧美日韩一区二区视频在线观看 | 精品国产鲁一鲁一区二区张丽 | 我想看国产一级毛片 | 欧美日韩免费 | 亚洲美女网站 | 亚洲欧美在线视频 | 精品中文字幕视频 | 欧美日韩一区二区在线 | 五月天婷婷丁香 | 国产精品久久久久久久免费大片 | 国产精品久久久久久久久久免费看 | 福利国产 | 国产精彩视频在线观看 | 日韩av在线中文字幕 |