那是我的jQuery代码:
$(function() {
$("#edit_union").click(function() {
var tuzove = $("#tuzove").val();
var description = $("#description").val();
var union_owner = $("#union_owner").val();
var union_name = $("#union_name").val();
var uid = $("#uid").val();
var dataString = 'tuzove='+ tuzove + '&description=' + description + '&union_owner=' + union_owner + '&union_name=' + union_name + '&uid=' + uid;
$.ajax({
type: "POST",
url: "ajax/admp_ajax.php",
data: dataString,
success: function() {
$(".adm_panel_serach_user").append("<br/><span style=' color: #0099ff; font-weight: bold;'>Success.</span>");
}
});
return false;
});
});
也就是 ajax/admp_ajax.php 页面:
include_once 'classes/admin_panel.php';
$admpanel = new adminPanal();
if ($_POST['tuzove'] && $_POST['description'] && $_POST['union_owner'] && $_POST['union_owner'] && $_POST['uid'])
$admpanel->editUnion($_POST['tuzove'], $_POST['description'], $_POST['union_owner'], $_POST['union_name'], $_POST['uid']);
那就是editUnion函数:
public function editUnion($tyzove, $description, $ownerName, $unionName, $unionId) {
mysql_query("UPDATE `union` SET tuzove = '" . $tyzove . "', description = '" . mysql_real_escape_string($description) . "', owner_id = '" . $this->getUserId($ownerName) . "' WHERE name = '" . $unionName . "'");
if ($ownerName == $ownerName)
mysql_query("UPDATE users SET union_rank = '0', union_id = '0' WHERE username = '" . $ownerName . "'");
mysql_query("UPDATE users SET union_rank = '1', union_id = '" . $unionId . "' WHERE username = '" . $ownerName . "'");
}
问题是,当我单击 edit_union 按钮时写入 Success,但不更新 union :(。