1
我希望控制器從efund_2.phtml返回變量的值當AJAX請求通過控制器做出,但其返回發起方的(efund.phtml)整個獲取整個頁面,而不是僅僅變量值HTML。Magento的通過控制器
/**
* Called using AJAX POST method.
*/
public function getEfundAction()
{
// Get post data.
$PostData = $this->getRequest()->getPost();
$Param1 = $PostData['param1'];
$Param2 = $PostData['param2'];
$ModelLayout = new Pteb_System_Model_Layout_Backend();
$ModelLayout->LoadLayout();
$Block = $ModelLayout->SetContentBlock('efund-block', 'Pteb_System_Block_Cms');
$Block->setTemplate('adminpteb/efund/efund_2.phtml');
// Passing parameters to template file.
$Block->setData('MyPostData1', $Param1);
$Block->setData('MyPostData2', $Param2);
$ModelLayout->ShowLayout();//this getting the whole page html. But I just need the value returned by the variables in the page(efund_2.phtml).
}
efund.phtml頁面的PHP函數。
$('a').bind('click', function(){
GetEFund();
});
我得到這個錯誤:像你需要設置JSON頭在你的控制器
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
In the network tab (Chrome console), I see the call is made to the function getEfund(). However when clicked on it, it shows the entire html of efund.phtml page , in fact that was what returned by the controller. How can I make efund_2.phtml return its variables?