ajax在Zend失败了 [英] ajax is failing in Zend
本文介绍了ajax在Zend失败了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是发送请求的JavaScript代码
This is the JavaScript code to send request
$.ajax({url: "/"+ controller +"/"+ action+"/", type: 'POST', dataType: 'html', data: parameter, contentType:"html", timeout: 90000, success: container, error:function (xhr, ajaxOptions, thrownError){
if(xhr.status==404){
alert(ajaxOptions);
}}});
控制器:客户
行动:添加
这是我的init函数在CustomerController类中
controller: Customer
action: add
here is my init function in CustomerController class
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('add', 'html');
$ajaxContext->initContext();
}
public function addAction()
{
// $this->_helper->layout()->disableLayout();
// $this->_helper->viewRenderer->setNoRender(true);
}
现在,页面总是收到404错误。我缺少什么?
我使用的是zend framework 1.12.4
Now, page is always getting 404 error. What am I missing?
I am using zend framework 1.12.4
推荐答案
.ajax({ url: / + controller + / + action + / ,键入:' POST',dataType:' html',data:parameter,contentType: html,超时: 90000 ,成功:容器,错误:功能(xhr,ajaxOptions ,thrownError){
if (xhr.status == 404 ){
alert(ajaxOptions);
}}});
.ajax({url: "/"+ controller +"/"+ action+"/", type: 'POST', dataType: 'html', data: parameter, contentType:"html", timeout: 90000, success: container, error:function (xhr, ajaxOptions, thrownError){ if(xhr.status==404){ alert(ajaxOptions); }}});
控制器:客户
操作:添加
这是我在CustomerController类中的初始化函数
controller: Customer
action: add
here is my init function in CustomerController class
public function init()
{
ajaxContext =
ajaxContext =
this-> _helper-> getHelper(' AjaxContext');
this->_helper->getHelper('AjaxContext');
这篇关于ajax在Zend失败了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文