Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在zend framework 2中使用ajax发布值_Javascript_Php_Jquery_Ajax_Zend Framework2 - Fatal编程技术网

Javascript 在zend framework 2中使用ajax发布值

Javascript 在zend framework 2中使用ajax发布值,javascript,php,jquery,ajax,zend-framework2,Javascript,Php,Jquery,Ajax,Zend Framework2,我使用ajax发布一个值,如下所示, 但是我发布的数据不会到达控制器ajaxAaction 查看脚本(是tpl文件) 以及动作 public function ajaxAction() { //get post request (standart approach) $request = $this->getRequest()->getPost(); //referring to the index //gets val

我使用ajax发布一个值,如下所示, 但是我发布的数据不会到达控制器
ajaxAaction

查看脚本(是tpl文件)

以及动作

 public function ajaxAction() {
       //get post request (standart approach) 

       $request = $this->getRequest()->getPost();

       //referring to the index
       //gets value from ajax request 
       $message = $request['message'];

      // makes disable renderer
      $this->_helper->viewRenderer->setNoRender();

      //makes disable layout
      $this->_helper->getHelper('layout')->disableLayout();

     //return callback message to the function javascript
     echo $message;
}


  } );
$.post('index/ajax',
是我认为错误所在的部分

我是否以错误的方式定义控制器和操作? 我被困在这里有一段时间了。
请帮助在
索引/ajax
中使用
$this->basePath()
进行尝试,通过在
根路径前面加前缀来解决问题,如下所示

  if (message != '') { 
                  //run ajax  rootPath
                {/literal}  $.post("{eval var=$rootPath}/index/ajax", {literal}
                            {'message' : message}, 

                            //callback function
                            function (respond) {

抱歉,这没有帮助:(好的,然后在firebug中检查表单提交数据的位置。firebug确实说该操作不存在,但它确实存在!
 public function ajaxAction() {
       //get post request (standart approach) 

       $request = $this->getRequest()->getPost();

       //referring to the index
       //gets value from ajax request 
       $message = $request['message'];

      // makes disable renderer
      $this->_helper->viewRenderer->setNoRender();

      //makes disable layout
      $this->_helper->getHelper('layout')->disableLayout();

     //return callback message to the function javascript
     echo $message;
}


  } );
  if (message != '') { 
                  //run ajax  rootPath
                {/literal}  $.post("{eval var=$rootPath}/index/ajax", {literal}
                            {'message' : message}, 

                            //callback function
                            function (respond) {