Skip to main content
Bounty Ended with 50 reputation awarded by Liam McArthur
deleted 34 characters in body
Source Link
Chirag Rajput
  • 1.5k
  • 10
  • 23

You need to change your controller code as below:

public function indexAction() {
    $this->loadLayout();
    $this->renderLayout();
}

public function ajaxAction() {
    $isAjax = Mage::app()->getRequest()->isAjax();
    if ( $isAjax ) {
        $output = $this->getLayout()->createBlock('finance/finance')->setTemplate('finance/ajax.phtml')->toHtml();
        $this->getResponse()->setHeader( 'Content-type', 'application/json' );
        $this->getResponse()->setBody( Mage::helper( 'core' )->jsonEncode( arrayjson_encode( 'outputHtml'['outputHtml' => $output ) $output]) );
    }
}

}

You need to change your controller code as below:

public function indexAction() {
    $this->loadLayout();
    $this->renderLayout();
}

public function ajaxAction() {
    $isAjax = Mage::app()->getRequest()->isAjax();
    if ( $isAjax ) {
        $output = $this->getLayout()->createBlock('finance/finance')->setTemplate('finance/ajax.phtml')->toHtml();
        $this->getResponse()->setHeader( 'Content-type', 'application/json' );
        $this->getResponse()->setBody( Mage::helper( 'core' )->jsonEncode( array( 'outputHtml' => $output ) ) );
    }
}

}

You need to change your controller code as below:

public function indexAction() {
    $this->loadLayout();
    $this->renderLayout();
}

public function ajaxAction() {
    $isAjax = Mage::app()->getRequest()->isAjax();
    if ( $isAjax ) {
        $output = $this->getLayout()->createBlock('finance/finance')->setTemplate('finance/ajax.phtml')->toHtml();
        $this->getResponse()->setHeader( 'Content-type', 'application/json' );
        $this->getResponse()->setBody(json_encode(['outputHtml' => $output]));
    }
}

}

Source Link
Chirag Rajput
  • 1.5k
  • 10
  • 23

You need to change your controller code as below:

public function indexAction() {
    $this->loadLayout();
    $this->renderLayout();
}

public function ajaxAction() {
    $isAjax = Mage::app()->getRequest()->isAjax();
    if ( $isAjax ) {
        $output = $this->getLayout()->createBlock('finance/finance')->setTemplate('finance/ajax.phtml')->toHtml();
        $this->getResponse()->setHeader( 'Content-type', 'application/json' );
        $this->getResponse()->setBody( Mage::helper( 'core' )->jsonEncode( array( 'outputHtml' => $output ) ) );
    }
}

}