2013-03-07 83 views
0

我正在开发一个AJAX注册表单,它将被提交给Zend框架。目前,表单的操作似乎没有执行。响应文本是当前HTML文档的副本。有人可以告诉我我做错了什么,以及正确的URL应该是什么?我已经使用模块设置了项目。例如,应该从例子中,正确的URL下面是:“/帐号/注册/ AUTH”Zend框架1提交表单url/action

#application.ini 
resources.router.routes.register.route = /register 
resources.router.routes.register.defaults.module = account 
resources.router.routes.register.defaults.controller = register 
resources.router.routes.register.defaults.action = index 

#application/modules/accout/controllers/RegisterController.php 
<?php 
    class Account_RegisterController extends Zend_Controller_Action{ 
     public function init(){ 
      $this->view->register = new Account_Form_Register(); 
     } 

     public function indexAction(){ 

     } 

     public function authAction(){ 
      $request = $this->getRequest(); 
      $form = new Account_Form_Register(); 

      if($request->isPost()){ 
       print('submit'); 
      }else{ 
       print('nothing yet'); 
      } 
     } 
    } 
?> 

#application/modules/account/views/scripts/register/index.phtml 
<div class="register"> 
     <form id="registerForm"> 
      <h2 class="formHeader">Register</h2> 

      <div class="floatLeft"> 
       <?php echo $this->register->fName; ?> 
      </div> 
      <div class="remaining"> 
       <?php echo $this->register->lName; ?> 
      </div> 

      <div class="floatLeft"> 
       <?php echo $this->register->uEmail; ?> 
      </div> 
      <div class="remaining"> 
       <?php echo $this->register->aEmail; ?> 
      </div> 

      <div class=""> 
       <?php echo $this->register->phone; ?> 
      </div> 

      <div class="floatLeft"> 
       <?php echo $this->register->oPassword; ?> 
      </div> 
      <div class="remaining"> 
       <?php echo $this->register->cPassword; ?> 
      </div> 

      <div id="formButton"> 
       <?php echo $this->register->submit; ?> 
      </div> 
     </form> 
</div> 
+0

看看可能是你应该禁用当你正在做的AJAX操作的视图处理(因为你使用的回声,如'回声json_encode($ some_data) ;'并且你不想返回任何东西 – MatRt 2013-03-07 04:58:56

+0

把表单改成非AJAX文章的结果是一样的 – Josh 2013-03-07 14:36:22

+0

你能给我们你的HTML代码吗?一般来说,URL应该像http:// your_site/your_controller/your_action,你可以在一些GET参数之后像'?var = value'或'/ value'这取决于你的配置灰。 – MatRt 2013-03-07 21:26:12

回答

-1

正如我所说的,也许你应该做的AJAX行动,以便返回json_encode($some_data),而不是当禁用了该视图处理的HTML内容。

尝试

$this->_helper->viewRenderer->setNoRender(true); 

this article

+0

我不认为他指的是他的观点没有被呈现,或者他的观点有问题。他似乎无法用正常的http调用执行操作(不涉及ajax请求);他的问题可能与问题中提到的路线有关。 – 2013-03-07 11:47:23

+0

试图找到解决方案。事实上,这个观点似乎并不是直接的问题,但当他使用ajax过程时,这可能是一个未来的问题。找到一个解决方案,而不是投下来... – MatRt 2013-03-07 21:34:05