Home  >  Article  >  Backend Development  >  xajax+smarty problem_PHP tutorial

xajax+smarty problem_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:52:31856browse

xajax+smarty Question Urgent!

My refreshContent function cannot be called. I have been troubled by this problem for several days. I just can't find where the problem lies. I hope you can help me find it. Thank you!
The code is as follows:

xajax_smarty.php

require_once( 'Config/Config.inc.php');
require_once('xajax/xajax_core/xajax.inc.php');
$xajax = new xajax();
function loadContent($n){
Global $Smarty;
If($n==0){
$data[] = array('title' =>'helloworld','content' =>'

what is going on?

');
$data[] = array('title' =>'another item','content' => '

nothing fancy

');
          }
        else if($n == 1){
echo '=============';
                  $data[] = array('title' =>'Dynamically loaded' , 'content' => '

There you go

');
          }
$Smarty ->assign('posts' ,$data);
$ret = $Smarty ->fetch('post.html');
$Smarty ->clear_all_assign();
Return $ret;
}
Function refreshContent($formValues){//cannot be called
echo "ldkfjdl";
$response= new xajaxResponse();
$newContent = loadContent($formValues['select_page']);
$response ->addAssign('content' , 'innerHTML' , $newContent);
Return $response;
}
$xajax ->registerFunction('refreshContent');
$xajax->processRequest();

$Smarty ->assign('content' , loadContent(0));
$Smarty ->assign('xajaxjavascript' , $xajax ->getJavascript('xajax/'));
$Smarty ->display('main.html');
?>

post.html


<%{foreach from = $posts item = post}%>

<%{$post.title}%>


<%{$post.content}%>

<%{/foreach }%>



main.html


<%{$xajaxjavascript}%>




Change content



<%{$content}%>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632483.htmlTechArticlexajax+smarty The problem is urgent! My refreshContent function cannot be called. I have been troubled by this problem for several days. I just can’t find where the problem lies. I hope everyone can help me, thank you...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn