EDIT2:OK、その情報で、私はテストしました。1つのファイルを使用していると思うので、テスト用にモックphpファイルを設定しました。onCompleteを削除し、更新でdivを設定しました。これが機能する結果です。それが役立つかどうか教えてください:
<?php
if ( isset($_GET['Nbr']) ){
// here Nbr is set, so we drop into outputting xml... you can do more before this
// and you can open a separate file, but didn't know how things were set up for you.
header('Content-Type: text/xml');
$out = $_GET['Nbr'].','
.(isset($_GET['Strt'])?$_GET['Strt']:'').','
.(isset($_GET['Bar'])?$_GET['Bar']:'').','
.(isset($_GET['FightType'])?$_GET['FightType']:'').','
.(isset($_GET['Action'])?$_GET['Action']:'');
print '<?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'><span>'.htmlentities($out).'</span>';
exit();
}
?>
<html>
<head>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">
function fightit(nbr,strt,bar,type,action) {
var params = "Nbr=" + nbr
+ "&Strt=" + strt
+ "&Bar=" + bar
+ "&FightType=" + type
+ "&Action=" + action;
alert(params);
// this is actually calling itself with '/t.php' and updating div01
new Ajax.Updater('div01', '/t.php', {method: 'get', parameters: params});
}
</script>
</head>
<body>
<table style="border-style:none;">
<tr>
<td style="border-style:none;">
<input style="width:150px; text-align:center;" type="button" value="Steal" onclick="stealit()" />
</td>
<td id="fightBtn" style="border-style:none;"><input style="width:150px; text-align:center;" type="button" value="Fight" onclick="fightit(0,0,0,0,0)" />
</td>
</tr>
<div id="div01"></div>
</body>
</html>
オリジナル:
ファイトタイプエラーが発生します。これは、チェックしても、チェック後に再チェックせずに使用しているためです($_GET['FightType']
まだ存在していません)。これを試して:
if (isset($_GET['FightType'])) {
$fighttype = $_GET['FightType'];
}
else {
$fighttype = 0;
}
$s = $fighttype;
編集:ajaxを修正するには、次のようなパラメーターを試してください(関数変数名を変更する必要がある場合があります):
new Ajax.Updater('div01', 'php/fight.php', {method: 'get', parameters: {Nbr: nbr, Strt: strt, Bar: bar, FightType: type, Action: action}, onComplete: div05F})