0
这是我的设置。与jQuery和.ajax问题 - 空白回复
我有一个HTML登记表,当用户在用户名已经输入,电子邮件等信息将被发送这样的:
var processFile = "../inc/ajax.inc.php";
$("#register").change(function(){
var postdata = $("#register").serialize();
$.ajax({
type: "POST",
url: processFile,
data: "action=reg_validation&" + postdata ,
success: function(data){
}
});
console.log("action=reg_validation&" + postdata);
});
这版画例如:
action=reg_validation&u=user&p=123&p2=&e=&r=
我ajax.inc.php文件:
/*
* Create a lookup array for form actions
*/
$actions = array(
'reg_validation' => array(
'object' => 'Intro',
'method' => 'check_reg_form'
)
);
if (isset($actions[$_POST['action']]))
{
$use_array = $actions[$_POST['action']];
$obj = new $use_array['object'];
echo $obj->$use_array['method'];
}
function __autoload($class_name)
{
$filename = '../../sys/class/class.'
. strtolower($class_name) . '.inc.php';
if (file_exists($filename))
{
include_once $filename;
}
}
此代码应该调用一个名为类0和class.intro.inc.php
中称为check_reg_form
的函数。这工作差不多。
如果我开始class.intro.inc.php
有:
echo "test 1";
exit();
我得到响应test 1
,但这不起作用:
class Intro
{
public function check_reg_form()
{
echo "test 2";
}
}
不知道为什么这不工作...我得到当我应该得到一个空白的回应test 2
..
正确!谢谢 :) – ganjan 2011-03-30 16:18:02