<?php
/*
/com_mycomponent
|-/views
| |-/response
| |-/tmpl
| | |-default.php
| | |-index.html
| |-view.raw.php
*/
?>
<?php
//default.php
defined('_JEXEC') or die('Restricted access');
echo $this->response;
?>
<?php
//view.raw.php
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.view');
class MycomponentViewResponse extends JView{
public function plain($tpl=null){
$this->setLayout('default');
parent::display($tpl);
}
public function json($tpl=null){
$this->response = json_encode($this->response);
$this->setLayout('default');
parent::display($tpl);
}
}
?>
<?php
//somewhere in a controller
public function check(){
$view = &$this->getView('response','raw');
$view->response = 'OK';
$view->plain();
}
?>
In your ajax call use the following base URL:
index.php?option=com_mycomponent&format=raw&
Then append the right controller & task parameters to the url, like:
index.php?option=com_mycomponent&format=raw&controller=mycontroller&task=check
php
1
<?php/* /com_mycomponent |-/views | |-/response | |-/tmpl | | |-default.php | | |-index.html | |-view.raw.php */?><?php//default.phpdefined('_JEXEC')ordie('Restricted access');echo$this->response;?><?php//view.raw.phpdefined('_JEXEC')ordie('Restricted access');jimport('joomla.application.component.view');classMycomponentViewResponseextendsJView{publicfunctionplain($tpl=null){$this->setLayout('default');parent::display($tpl);}publicfunctionjson($tpl=null){$this->response=json_encode($this->response);$this->setLayout('default');parent::display($tpl);}}?><?php//somewhere in a controllerpublicfunctioncheck(){$view=&$this->getView('response','raw');$view->response='OK';$view->plain();}?>In your ajax call use the following base URL:index.php?option=com_mycomponent&format=raw&Then append the right controller & task parameters to the url, like:index.php?option=com_mycomponent&format=raw&controller=mycontroller&task=check
Hey there! I see you're running Internet Explorer 6.
That's neat. This reminds me of my grandpa. He had this old car that he kept having to fix. He spent so much money on it that he didn't want to get rid of it (even when it stopped running).
0 Comments