[XAJAX] 同一頁面使用兩個以上副程式發生的錯誤

edited 十月 2013 in 進階PHP討論
請先看以下的網址:

http://nidgetgod.no-ip.org/mp3player/test.php

因為實在找不到解決方法沒辦法繼續寫下去

目前實際上有作用的只有『申請播放器』和下面的『登入表單』

你可以先試看看登入表單確定他是可以正常運作的

然後點選『申請播放器』會跳出『申請表單』

接著問題來了

跳出表單後再回去按『登入』鈕

發生非預期的錯誤了

不曉得有哪位前輩曉得是怎麼一回事呢?

原碼參考:
<?php

  require_once ("xajax/xajax.inc.php");

  $xajax = new xajax("system.server.php");
  $xajax->registerFunction("login");
  $xajax->registerFunction("register_form");

function login($users, $password) {
  if( empty($users) || strlen($users) < 8 )
    $Msg = "* 帳號至少 8 個字元";
  else if( empty($password) || strlen($password) < 8 )
    $Msg = "* 密碼至少 8 個字元";
  else {
    $Num = 0; // 假設找不到該使用者帳號

    if( $Num == 0 )
      $Msg = "* 請確認帳號、密碼是否正確";
    else
     $Msg = "* 登入成功";
  }

  $objResponse = new xajaxResponse();
  $objResponse->addAssign("box0", "innerHTML", $Msg);
  return $objResponse;
}

function register_form() {
  $Data = '			<table id="register_table" name="register_table">
				<tr>
					<td colspan="2" id="title"></td>
				</tr>
				<tr>
					<td colspan="2" id="box0"></td>
				</tr>
				<tr>
					<td id="box1">*帳號</td>
					<td id="box2"><input type="text" id="users" name="users" /></td>
				</tr>
				<tr>
					<td id="box1">*密碼</td>
					<td id="box2"><input type="password" id="password" name="password" /></td>
				</tr>
				<tr>
					<td id="box1">*密碼確認</td>
					<td id="box2"><input type="password" id="password_confirm" name="password_confirm" /></td>
				</tr>
				<tr>
					<td id="box1">信箱</td>
					<td id="box2"><input type="text" id="email" name="email" /></td>
				</tr>
				<tr>
					<td id="box1">網站名稱</td>
					<td id="box2"><input type="text" id="webtitle" name="webtitle" /></td>
				</tr>
				<tr>
					<td id="box1">網站網址</td>
					<td id="box2"><input type="text" id="weburl" name="weburl" /></td>
				</tr>
				<tr>
					<td colspan="2" id="box3"><input type="button" id="submit" name="submit" value="註 冊" 
onClick="xajax_register(document.getElementById(\'users\').value, document.getElementById(\'password\').value
, document.getElementById(\'password_confirm\').value
, document.getElementById(\'email\').value
, document.getElementById(\'webtitle\').value)
, document.getElementById(\'weburl\').value;return false;" /></td>
				</tr>
			</table>';

  $objResponse = new xajaxResponse();
  $objResponse->addAssign("main", "innerHTML", $Data);
  return $objResponse;
}

  $xajax = new xajax("system.server.php");
  $xajax->registerFunction("login");
  $xajax->registerFunction("register_form");
  $xajax->processRequests();


?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>Flash Mp3 Player 播放器申請鋪</title>
<?php $xajax->printJavascript( 'xajax/' ); ?>
</head>
<body>

<div id="container">
	<div id="banner"></div>
	<div id="main"></div>
	<div id="menu">
		<div id="top_menu">
			<a href="" onClick="xajax_register_form();return false;">申請播放器</a>
		</div>
		<div id="bottom_menu">
			<table id="login_table" name="login_table">
				<tr>
					<td colspan="2" id="title"></td>
				</tr>
				<tr>
					<td colspan="2" id="box0"></td>
				</tr>
				<tr>
					<td id="box1">帳號</td>
					<td id="box2"><input type="text" id="users" name="users" /></td>
				</tr>
				<tr>
					<td id="box1">密碼</td>
					<td id="box2"><input type="password" id="password" name="password" /></td>
				</tr>
				<tr>
					<td colspan="2" id="box3"><input type="button" id="submit" name="submit" value="登 入" 
onClick="xajax_login(document.getElementById('users').value
, document.getElementById('password').value);return false;" /></td>
				</tr>
			</table>
		</div>
	</div>
</div>

</body>
</html>

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=1989

評論

Sign In or Register to comment.