它假设从db获取一个帐户并生成它,但是当我点击按钮时它根本就没有做任何事情。
这非常重要,但它不起作用。我错过了我需要放的东西吗?如果是这样,请告诉我,并将其添加。
<?php
if ($generator == "") {
$generatorquery = "SELECT * FROM `accounts`";
} else {
$generatorquery = "SELECT * FROM `accounts` WHERE `id` = " . $generator;
}
$result = mysqli_query($con, $generatorquery) or die(mysqli_error($con));
while ($row = mysqli_fetch_array($result)) {
echo '
<div class="col-sm-6 col-lg-4">
<div class="panel panel-success">
<div class="panel-heading">
<span class="panel-title">' . $row["name"] . ' Generator</span>
<div class="widget-menu pull-right">
</div>
</div>
<div class="panel-body">
<script>
$(document).ready(function(){
$("#' . $row['name'] . '").click(function(){
$("p[class=' . $row["name"] . ']").load("generate.php?account=' . $row["name"] . '&username=' . $username . '",function(responseTxt,statusTxt,xhr){
if(statusTxt=="error")
alert("Error: "+xhr.status+": "+xhr.statusText);
});
});
$("#' . $row["name"] . '").click();
});
</script>
<p class="' . $row["name"] . '"></p>
<button type="button" id="' . $row["name"] . '" class="btn btn-success">Generate</button>
</div>
</div>
</div>
';
}
答案 0 :(得分:0)
无论发生什么,if (statusTxt=="error")
都不是错误,而只是PHP提供的输出类型之一。它是success
函数。所以将代码更改为:
alert("Error: " + statusTxt.status + ": " + statusTxt.statusText);