喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 帮助

RSS 订阅当前论坛  

喜悦证交所已经关闭

上一主题 下一主题
     
标题: [问题] 在类框架下使用xajax的问题,请教  
 
Ultrawind
注册会员
Rank: 2
一般会员



UID 67136
精华 0
积分 188
帖子 206
金钱 188 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-10-7
状态 离线
[广告]: q m
在类框架下使用xajax的问题,请教

在类框架下使用xajax的问题,请教


index.class.php
<?php
require_once(xajax/xajax_core/xajax.inc.php");
class IndexClass
{
   function register() {
     $this->xajax = new xajax();
     $this->xajax->setFlag("debug", true);
     $this->xajax->registerfunction("checkUserName");
     $this->xajax->processRequest();
    }
    function checkUserName($user_name) {
     $objresponse = new xajaxresponse();
     $objresponse->assign("user_name_div","innerHTML", "ok");
     return $objresponse;
    }
}
?>

index_register.php
<?php
include("index.class.php");
$index = new IndexClass();
$index->register();
?>
<html>
<head>
<?php $this->xajax->printjavascript("lib/plugin/xajax/"); ?>
</head>
<body>
<table>
<tr>
       <td >用户名:</td>
       <td ><input type="text" name="user_name"  ></td>
       <td ><div id="user_name_div"></div></td>
      </tr>
</table>
</body>
</html>




运行xajax报错:
<b>Warning</b>: call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'checkUserName' was given in <b>F:\www\project\lib\plugin\xajax\xajax_core\plugin_layer\support\xajaxUserFunction.inc.php</b> on line <b>229</b><br />


看样子是找不到 checkUserName 这个函数。

我想问问在这种类架构下,xajax应该如果registerfunction才能找到checkUserName呢?

或者怎么改变写法呢?
2007-9-12 12:41 PM#1
查看资料  发短消息  顶部
 
喜悦村支书
中级会员
Rank: 3Rank: 3


UID 82061
精华 0
积分 210
帖子 258
金钱 210 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2006-10-23
状态 离线
[推荐阅读] 上海外商独资科技公司全国招聘phper
这个问题挺抽象的呢..呵呵....我有以下几种想法,请考虑:

   1: 打印javascript时应该这样写index->xajax->printjavascript("lib/plugin/xajax/"),在这里$this应该不指向什么的.
   2: 除非你把checkUserName放在index_register.php里面来声明,否则$index这个指针应该找不到您的这个函数,建议您改成这样的试试:
      
    class IndexClass
{
var $xajax;//声明一下好.
var $callBackFunction;
   function register($functionName) {
     $this->xajax = new xajax();
     $this->xajax->setFlag("debug", true);
     $this->xajax->registerfunction($functionName);
     $this->xajax->processRequest();
    }
    function checkUserName($user_name) {
     $objresponse = new xajaxresponse();
     $objresponse->assign("user_name_div","innerHTML", "ok");
     return $objresponse;
    }
}
   用的时候你这样:
               $index = new IndexClass();
               $index->callBackFunction = "checkUserName";
               $index->register($index->callBackFunction);

   3,没有看到您在哪里触发的ajax事件.
   4,如何请不要写成"如果"呀,虽然能懂你的意思,可是太别扭啦...
2007-9-12 02:23 PM#2
查看资料  发短消息  顶部
 
Ultrawind
注册会员
Rank: 2
一般会员



UID 67136
精华 0
积分 188
帖子 206
金钱 188 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-10-7
状态 离线
[推荐阅读] 在discuz6.0中 common.inc.php文件中碰到一个问题,帮忙解答,谢谢
谢谢支书意见。
按照你的方法来做,还是找不到checkUserName这个函数。

另外触发ajax那里应该是
<tr>
       <td >用户名:</td>
       <td ><input type="text" name="user_name"  onblur="xajax_checkUserName(this.value)"></td>
       <td ><div id="user_name_div"></div></td>
      </tr>
2007-9-12 03:24 PM#3
查看资料  发短消息  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.023150 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP