<bdo id='d1D79'></bdo><ul id='d1D79'></ul>

      <i id='d1D79'><tr id='d1D79'><dt id='d1D79'><q id='d1D79'><span id='d1D79'><b id='d1D79'><form id='d1D79'><ins id='d1D79'></ins><ul id='d1D79'></ul><sub id='d1D79'></sub></form><legend id='d1D79'></legend><bdo id='d1D79'><pre id='d1D79'><center id='d1D79'></center></pre></bdo></b><th id='d1D79'></th></span></q></dt></tr></i><div id='d1D79'><tfoot id='d1D79'></tfoot><dl id='d1D79'><fieldset id='d1D79'></fieldset></dl></div>

      <legend id='d1D79'><style id='d1D79'><dir id='d1D79'><q id='d1D79'></q></dir></style></legend>
      <tfoot id='d1D79'></tfoot>

      <small id='d1D79'></small><noframes id='d1D79'>

      1. 使用 Zend Action Helper ContextSwitch 创建自定义 JSON 响应对象

        Creating a custom JSON response object with Zend Action Helper ContextSwitch(使用 Zend Action Helper ContextSwitch 创建自定义 JSON 响应对象)

      2. <tfoot id='mRnU7'></tfoot>
            <tbody id='mRnU7'></tbody>
        • <small id='mRnU7'></small><noframes id='mRnU7'>

              <legend id='mRnU7'><style id='mRnU7'><dir id='mRnU7'><q id='mRnU7'></q></dir></style></legend>

              <i id='mRnU7'><tr id='mRnU7'><dt id='mRnU7'><q id='mRnU7'><span id='mRnU7'><b id='mRnU7'><form id='mRnU7'><ins id='mRnU7'></ins><ul id='mRnU7'></ul><sub id='mRnU7'></sub></form><legend id='mRnU7'></legend><bdo id='mRnU7'><pre id='mRnU7'><center id='mRnU7'></center></pre></bdo></b><th id='mRnU7'></th></span></q></dt></tr></i><div id='mRnU7'><tfoot id='mRnU7'></tfoot><dl id='mRnU7'><fieldset id='mRnU7'></fieldset></dl></div>
                <bdo id='mRnU7'></bdo><ul id='mRnU7'></ul>
                  本文介绍了使用 Zend Action Helper ContextSwitch 创建自定义 JSON 响应对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我通常会在响应正文中附加一个编码的 json 对象,但是现在我遇到了需要使用 ContextSwitch 操作助手的情况.

                  I normally append an encoded json object to the response body, however I now have a situation that warrants using the ContextSwitch action helper.

                  我有一个 Zend_Form 需要三个不同的响应上下文:

                  I have a Zend_Form that requires three different response contexts:

                  1. html - 将表单呈现为普通的 html在布局内.
                  2. html-partial - 呈现的 ajaxget"请求只是表单为 html.
                  3. json - 返回的 ajaxpost"请求任何形式验证错误消息.
                  1. html - Render the form as normal html within a layout.
                  2. html-partial - An ajax "get" request that renders just the form as html.
                  3. json - An ajax "post" request that returns any form valiation error messages.

                  对于每个上下文,我有 3 个视图脚本.虽然这两个html上下文可以使用同一个视图脚本,但是我还没有弄清楚这是否可能.

                  For each context I have 3 view scripts. Although the two html contexts could use the same view script, but I haven't figured out if this is possible.

                  • form.phtml
                  • form.html.phtml
                  • form.json.phtml

                  html 上下文视图可以正常工作,但是 json 视图没有被选中.覆盖默认 json post 回调行为或将自定义编码对象传递给响应正文的最佳方法是什么?

                  The html context views work okay, but the json view is not being picked up. What is the best method to override the default json post callback behaviour or pass a custom encoded object to the response body?

                  推荐答案

                  就我个人而言,我不使用视图"来生成 JSON 内容.在我的 init() 中,我有这样的东西:

                  Personally, I don't use "View" to generate JSON content. In my init(), I have something like this:

                  $ajaxContext = $this->_helper->getHelper('AjaxContext');
                  $ajaxContext->setAutoJsonSerialization(false)
                      ->addActionContext('index', array('html', 'json'))
                      ->initContext();
                  

                  在我的indexAction()中:

                  if ( true === $this->isAjaxJson() ) {
                      $this->_helper->json(
                          array(
                              'response' => $myResponse,
                              'message' => $myMesage
                          )
                      );
                      return;
                  }
                  

                  希望对您有所帮助.

                  这篇关于使用 Zend Action Helper ContextSwitch 创建自定义 JSON 响应对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    1. <tfoot id='Q9dnQ'></tfoot>

                        1. <legend id='Q9dnQ'><style id='Q9dnQ'><dir id='Q9dnQ'><q id='Q9dnQ'></q></dir></style></legend>
                            <bdo id='Q9dnQ'></bdo><ul id='Q9dnQ'></ul>
                          • <small id='Q9dnQ'></small><noframes id='Q9dnQ'>

                              <tbody id='Q9dnQ'></tbody>
                            <i id='Q9dnQ'><tr id='Q9dnQ'><dt id='Q9dnQ'><q id='Q9dnQ'><span id='Q9dnQ'><b id='Q9dnQ'><form id='Q9dnQ'><ins id='Q9dnQ'></ins><ul id='Q9dnQ'></ul><sub id='Q9dnQ'></sub></form><legend id='Q9dnQ'></legend><bdo id='Q9dnQ'><pre id='Q9dnQ'><center id='Q9dnQ'></center></pre></bdo></b><th id='Q9dnQ'></th></span></q></dt></tr></i><div id='Q9dnQ'><tfoot id='Q9dnQ'></tfoot><dl id='Q9dnQ'><fieldset id='Q9dnQ'></fieldset></dl></div>