教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 xajax smarty 问题

xajax smarty 问题

发布时间:2019-04-05   编辑:jiaochengji.com
教程集为您提供xajax smarty 问题等资源,欢迎您收藏本站,我们将为您提供最新的xajax smarty 问题资源

我的refreshContent函数调用不了,我已被这个问题困扰了好几天了 ,就是找不到问题出在哪了,希望大家帮我看看,谢谢!
代码如下:

xajax_smarty.php

<?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' =>'<p>what is going on?</p>');
       $data[] = array('title' =>'another item','content' => '<p>nothing fancy</p>');
            }
       else if($n == 1){
           echo '=============';
             $data[] = array('title' =>'Dynamically loaded' , 'content' => '<p>There you go</p>');
            }
       $Smarty ->assign('posts' ,$data);
       $ret = $Smarty ->fetch('post.html');
       $Smarty ->clear_all_assign();
       return $ret;
  }
   function refreshContent($formValues){//调用不了
     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
<html>
<body>
<%{foreach from = $posts item = post}%>
<div>
<h2><%{$post.title}%></h2>
<%{$post.content}%>
</div>
<%{/foreach }%>
</body>
</html>

main.html
<html>
<head>
<%{$xajaxjavascript}%>
</head>
<body>
<div id="header">
  <h1>Smarty $amp;xajax</h1>
</div>
<form id="frm_switcher" method="POST" >
   更换内容
   <select name = "select_page">
     <option value="0" selected='selected'>页面索引 0</option>
     <option value="1" > 页面索引 1</option>
   </select>
</form>
<div id ="content">
  <%{$content}%>
</div>
</body>
</html>

您可能感兴趣的文章:
xajax smarty 问题
smarty结合xajax检测用户名
smarty结合xajax检测用户名简单实例
smarty获得当前url示例代码
php的ajax框架xajax入门与试用
PHP模板引擎Smarty缓存使用
有关smarty的基本设置
smarty无法调用js脚本的解决方法
php smarty 基础
有关在smarty中调用php内置函数的问题

[关闭]
~ ~