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