Zend Framework和Jquery::Ajax-检查id是否可用-如何?

Zend Framework和Jquery::Ajax-检查id是否可用-如何?,ajax,zend-framework,Ajax,Zend Framework,对于给定的表单输入字段,上的模糊,我想检查输入值是否有效要知道该id是否有效,我需要查询数据库如果该选项无效,则应在输入字段旁边显示一条消息,指示该选项无效 不过,这是我第一次单独体验Ajax 我能有一个关于如何实现这样的东西的框架吗 我有点意识到像这样的东西应该被使用 if($this->getRequest()->isXmlHttpRequest()) { ... 但我真的需要帮助 非常感谢, MEM在Zend Framework中处理AJAX请求时,首先要注意的是禁用view

对于给定的表单输入字段上的模糊,我想检查输入值是否有效
要知道该id是否有效,我需要查询数据库
如果该选项无效,则应在输入字段旁边显示一条消息,指示该选项无效

不过,这是我第一次单独体验Ajax

我能有一个关于如何实现这样的东西的框架吗

我有点意识到像这样的东西应该被使用

if($this->getRequest()->isXmlHttpRequest()) {
...
但我真的需要帮助

非常感谢,

MEM

在Zend Framework中处理AJAX请求时,首先要注意的是禁用view/MVC布局组件

在你的行动中

    public function validateAction()
    {

    if($this->getRequest()->isXmlHttpRequest()) {
    //Disable the view/layout
    $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender(TRUE);

    //Receive the value from the form
    $inputValue = $this->_getParam('name');

    //Access your model and validate the data.

    $model = new Model();
    $result = $model->isValid($inputValue);


    $myArray = array(
                 'result'=>$result
               );

    $jsonData = Zend_Json::encode($myArray);
//Send the result back to the client
    $this->response->appendBody($jsonData);
    }
    }
从客户端接收这个JSON对象(使用jQuery),处理它并显示相应的消息


类似的问题-

在Zend Framework中处理AJAX请求时,首先要注意的是禁用view/MVC布局组件

在你的行动中

    public function validateAction()
    {

    if($this->getRequest()->isXmlHttpRequest()) {
    //Disable the view/layout
    $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender(TRUE);

    //Receive the value from the form
    $inputValue = $this->_getParam('name');

    //Access your model and validate the data.

    $model = new Model();
    $result = $model->isValid($inputValue);


    $myArray = array(
                 'result'=>$result
               );

    $jsonData = Zend_Json::encode($myArray);
//Send the result back to the client
    $this->response->appendBody($jsonData);
    }
    }
从客户端接收这个JSON对象(使用jQuery),处理它并显示相应的消息

类似的问题—