hi,i hope you can help me ! need your help!
i find my refreshContent function can't be invoked .
[code=php] <?php
require_once( 'Config/Config.inc.php' );
require_once('x ajax/xajax_core/xajax.inc.php') ;
$xajax = new xajax();
function loadContent($n) {
global $Smarty;
if($n==0){
$data[] = array('title' =>'helloworld', 'content' =>'<p>what is going on?</p>');
$data[] = array('title' =>'another item','content' => '<p>nothing fancy</p>');
}
else if($n == 1){
$data[] = array('title' =>'Dynamically loaded' , 'content' => '<p>There you go</p>');
}
$Smarty ->assign('post s' ,$data);
$ret = $Smarty ->fetch('post.ht ml');
$Smarty ->clear_all_assi gn();
return $ret;
}
function refreshContent( $formValues){// this function is not invoked;
echo "ldkfjdl";
$response= new xajaxResponse() ;
$newContent = loadContent($fo rmValues['select_page']);
$response ->addAssign('con tent' , 'innerHTML' , $newContent);
return $response;
}
$xajax ->registerFuncti on('refreshCont ent');
$xajax->processRequest ();
$Smarty ->assign('conten t' , loadContent(0)) ;
$Smarty ->assign('xajaxj avascript' , $xajax ->getJavascript( 'xajax/'));
$Smarty ->display('main. html');
?>
post.html
<html>
<body>
<%{foreach from = $posts item = post}%>
<div>
<h2><%{$post.ti tle}%></h2>
<%{$post.conten t}%>
</div>
<%{/foreach }%>
</body>
</html>
main.html
<html>
<head>
<%{$xajaxjavasc ript}%>
</head>
<body>
<div id="header">
<h1>Smarty $amp;xajax</h1>
</div>
<form id="frm_switche r" method="POST" >
change content:
<select name = "select_pag e" onchange = "xajax_refreshC ontent(xajax.ge tFormValues('fr m_switcher'));" >
<option value="0" selected='selec ted'>index 0</option>
<option value="1" > index 1</option>
</select>
</form>
<div id ="content">
<%{$content}% >
</div>
</body>
</html>[/code]
i find my refreshContent function can't be invoked .
[code=php] <?php
require_once( 'Config/Config.inc.php' );
require_once('x ajax/xajax_core/xajax.inc.php') ;
$xajax = new xajax();
function loadContent($n) {
global $Smarty;
if($n==0){
$data[] = array('title' =>'helloworld', 'content' =>'<p>what is going on?</p>');
$data[] = array('title' =>'another item','content' => '<p>nothing fancy</p>');
}
else if($n == 1){
$data[] = array('title' =>'Dynamically loaded' , 'content' => '<p>There you go</p>');
}
$Smarty ->assign('post s' ,$data);
$ret = $Smarty ->fetch('post.ht ml');
$Smarty ->clear_all_assi gn();
return $ret;
}
function refreshContent( $formValues){// this function is not invoked;
echo "ldkfjdl";
$response= new xajaxResponse() ;
$newContent = loadContent($fo rmValues['select_page']);
$response ->addAssign('con tent' , 'innerHTML' , $newContent);
return $response;
}
$xajax ->registerFuncti on('refreshCont ent');
$xajax->processRequest ();
$Smarty ->assign('conten t' , loadContent(0)) ;
$Smarty ->assign('xajaxj avascript' , $xajax ->getJavascript( 'xajax/'));
$Smarty ->display('main. html');
?>
post.html
<html>
<body>
<%{foreach from = $posts item = post}%>
<div>
<h2><%{$post.ti tle}%></h2>
<%{$post.conten t}%>
</div>
<%{/foreach }%>
</body>
</html>
main.html
<html>
<head>
<%{$xajaxjavasc ript}%>
</head>
<body>
<div id="header">
<h1>Smarty $amp;xajax</h1>
</div>
<form id="frm_switche r" method="POST" >
change content:
<select name = "select_pag e" onchange = "xajax_refreshC ontent(xajax.ge tFormValues('fr m_switcher'));" >
<option value="0" selected='selec ted'>index 0</option>
<option value="1" > index 1</option>
</select>
</form>
<div id ="content">
<%{$content}% >
</div>
</body>
</html>[/code]
Comment