11月
01
2011
CodeIgniter xajax
CodeIgniter 2.0.3へXajax 0.6 beta1を導入する
まずダウンロードhttp://www.xajax-project.org/en/download/
解凍すると [test] [xajax_core] [xjax_js] [xajax_plugins] copyright.inc.phpがあるので
[xajax_core]を[xajax]に変更してapplication/libraries/へ配置
[xajax_js]を配置index.phpと同じ場所でOK
xajax/xajax.inc.phpをxajax/xajax.phpへ変更
xajax_jsを他へ配置した場合は735行目あたりの
$sJsFile = ‘xajax_js/xajax_core.js’;を環境に合わせて変更
その時はxajax/plugin_layer/xajaxDefaultIncludePlugin.inc.phpの280行目あたりに
array($this->_getScriptFilename(‘xajax_js/xajax_core.js’), ‘xajax’);
という部分が4つほどあるのでこのパスも変更
class Test extends My_Controller {
function __construct() {
//ライブラリを読み込む
$this->load->library('xajax');
//ここにxajaxで実行したいfunctionを登録('test_function')
$this->xajax->register(XAJAX_FUNCTION, array(&$this, 'test_function'));
$this->xajax->processRequest();
}
function index(){
//登録functionの呼び出しはxajax_をつける
echo '$this->xajax->getJavascript(base_url().'assets/');
echo '
';
}
// xajaxで呼び出されて
//id="test_area"へ'xajaxで表示'を表示
function test_function(){
$res = new xajaxResponse();
$res->assign('test_area', 'innerHTML', 'xajaxで表示');
}
≪参考サイト≫
CodeIgniterでxajaxを利用する方法
CodeIgniter 1.6.3 と xajax 0.5 rc2 を組み合わせてみた