gpt4 book ai didi

javascript - 脚本在实际服务器中不起作用,但在本地主机 XAMPP 中起作用

转载 作者:行者123 更新时间:2023-11-29 20:46:28 25 4
gpt4 key购买 nike

我似乎找不到问题,因为我的代码在 localhost xampp 中工作。但一旦我上传到实际服务器,它就不起作用了。

没有任何错误输出

当我提交表单时,它会输出加载程序,然后消失,并且在<div id="status"></div>处没有输出成功消息或错误消息。

JavaScript:

<script>
function _(id){ return document.getElementById(id); }
function submitForm(){
_("bankbtn").disabled = true;
_("status").innerHTML = '<div class="progress"><div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"><span class="sr-only">Loading...</span></div></div><br />';
var formdata = new FormData();
formdata.append( "bcountry", _("bcountry").value );
formdata.append( "bname", _("bname").value );
formdata.append( "baname", _("baname").value );
formdata.append( "bno", _("bno").value );
formdata.append( "bswift", _("bswift").value );
var ajax = new XMLHttpRequest();
ajax.open( "POST", "editbank_engine.php" );
ajax.onreadystatechange = function() {
if(ajax.readyState == 4 && ajax.status == 200) {
if(ajax.responseText == "success"){

_("editbank").innerHTML = '<div class="alert alert-success"><h2>Changes has been saved</h2></div>';
} else {
_("status").innerHTML = ajax.responseText;
_("bankbtn").disabled = false;
}
}
}
ajax.send( formdata );
}
</script>

html

<div class="modal fade" id="edit" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Edit</h4>
</div>
<div class="modal-body">

<form id="editbank" onsubmit="submitForm(); return false;">
<div id="status"></div>
<input class="form-control" type="text" value="<?php echo $bank['bank_country']?>" id="bcountry" placeholder="Bank Country" required=""/><br />
<input class="form-control" type="text" value="<?php echo $bank['bank_name']?>" id="bname" placeholder="Bank Name" required=""/><br />
<input class="form-control" type="text" value="<?php echo $bank['bank_accountname']?>" id="baname" placeholder="Bank Account Name" required=""/><br />
<input class="form-control" type="text" value="<?php echo $bank['bank_no']?>" id="bno" placeholder="Bank Account No." required=""/><br />
<input class="form-control" type="text" value="<?php echo $bank['bank_swiftcode']?>" id="bswift" placeholder="Bank Swift Code"/><br />

</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button id="bankbtn" type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

php

<?php
session_start();
include_once('../php/config.php');
include_once('../php/func.php');
if(
isset($_SESSION['hotel_id']) &&
isset($_POST['bcountry']) &&
isset($_POST['bname']) &&
isset($_POST['baname']) &&
isset($_POST['bno']) &&
isset($_POST['bswift']) &&
!empty($_SESSION['hotel_id']) &&
!empty($_POST['bcountry']) &&
!empty($_POST['bname']) &&
!empty($_POST['baname']) &&
!empty($_POST['bno']) &&
!empty($_POST['bswift'])
){
$update = $dbo->prepare('UPDATE bank_details SET bank_country=:bankcountry, bank_name=:bankname, bank_accountname=:bankaccountname, bank_no=:bankno, bank_swiftcode=:bankswift, active=0, last_updated=NOW() WHERE hid=:hid AND active = 1');
$update->bindParam(':bankcountry', $_POST['bcountry'], PDO::PARAM_STR);
$update->bindParam(':bankname', $_POST['bname'], PDO::PARAM_STR);
$update->bindParam(':bankaccountname', $_POST['baname'], PDO::PARAM_STR);
$update->bindParam(':bankno', $_POST['bno'], PDO::PARAM_STR);
$update->bindParam(':bankswift', $_POST['bswift'], PDO::PARAM_STR);
//$update->bindParam(':active', '0', PDO::PARAM_STR);
$update->bindParam(':hid', $_SESSION['hotel_id'], PDO::PARAM_STR);
$update->execute();
if($update->rowCount() == 1){
echo 'success';
//echo '<div class="alert alert-success"><b>Changes has been saved</b></div>' ;
//mail_log('-User '.$_SESSION['extranet_user'].' has updated his bank details at '.date(time(), 'Y/m/d H:i:s').'');
}else{
echo '<div class="alert alert_danger"><strong>Error has occurred, You can only update once your account has been approved</strong></div>';
//mail_log(' User '.$_SESSION['extranet_user'].' has run into an error via bank details at '.date(time(), 'Y/m/d H:i:s').'');
}
}
?>

最佳答案

所以我发现了问题。它在我的 phpmyadmin (实际服务器)中我正在使用 id 为 0 的测试用户测试我的表单,我所要做的就是将其更改为 1,由于某种原因它不能设置为 0,否则它将无法工作

关于javascript - 脚本在实际服务器中不起作用,但在本地主机 XAMPP 中起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38412750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com