成功后我的页面不会重新加载,但它只是关闭窗口
这是我的 jQuery脚本
jQuery("#edit").dialog({
modal: true,
resizable: false,
draggable: false,
autoOpen: false,
width: 400,
buttons: [
{
text: "Ok",
click: function() {
var message = "";
var id = jQuery.trim(jQuery("#id").val());
var fname = jQuery.trim(jQuery("#firstname").val());
var lname = jQuery.trim(jQuery("#lastname").val());
var email = jQuery.trim(jQuery("#email").val());
var telephone = jQuery.trim(jQuery("#telephone").val());
var mobile = jQuery.trim(jQuery("#mobile").val());
var address = jQuery.trim(jQuery("#address").val());
var bdate = jQuery.trim(jQuery("#bdate").val());
if (fname == "") {message += "Please enter firstname\n"};
if (lname == "") {message += "Please enter lastname\n"};
if (email == "") {
message += "Please enter email\n"
}
else{
if(!ValidateEmail(email)){
message += "Please enter valid email address.\n"
}
}
if (telephone == "") {message += "Please enter telephone\n"};
if (mobile == "") {message += "Please enter mobile\n"};
if (address == "") {message += "Please enter address\n"};
if (bdate == "") {message += "Please enter birthdate"};
if (message != "")
{
alert(message);
return false;
}
else
{
jQuery.ajax({
type: "POST",
dataType: "json",
url: "update.php",
async:true,
data: {
"id": id,
"firstname": fname,
"lastname": lname,
"email": email,
"telephone": telephone,
"mobile": mobile,
"address": address,
"bdate": bdate
},
sucess: function(){
window.location.reload(true);
}
});
}
}
},
{
text: "Cancel",
click: function() {
jQuery(this).dialog( "close" );
}
}
]
});
这是我的 PHP
$id = $_POST['id'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$mobile = $_POST['mobile'];
$address = $_POST['address'];
$bdate = date("Y-m-d",strtotime($_POST['bdate']));
$sql = "UPDATE user SET
firstname='$firstname', lastname='$lastname', email='$email', telephone='$telephone', mobile='$mobile', address='$address', bdate='$bdate' WHERE id=$id";
$result = mysql_query($sql);
if($result){
echo json_encode(array(
"success" => true,
));
}
我也试过这个,但没有重新加载页面
sucess: function(data){
if(data.success == true){
window.location.reload(true);
}
}
我也将 window.location.reload 更改为 location.reload ,我还尝试删除其中的 true