$('.submit-clickable').click(function (e) {
let username = document.getElementById('susername');
let password = document.getElementById('spassword');
$(this).html("Saving ...");
if(username != null && password != null) {
e.preventDefault();
$.ajax({
type: "POST",
url: 'http://localhost:8000/board/settings/save',
data: { username: username, password: password },
success: function (message) {
$(this).html("Save Data");
alert(message);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Error Occured!" + " | " + XMLHttpRequest.responseText +
" | " + textStatus + " | " + errorThrown);
}
});
e.preventDefault();
}
});
和
<?php
include "system/user.php";
include "system/system.php";
$username = isset($_POST['username']) ? $_POST['username'] : null;
$password = isset($_POST['password']) ? $_POST['password'] : null;
$username_old = getUsername();
$password_old = getPasswordEncrypted(getId());
if($username != null && $password != null) {
if(!password_verify($password, $password_old)) {
updatePassword($password);
echo '1';
}
if($username != $username_old) {
//todo: Update name
echo '2';
}
echo 'success';
} else {
echo 'no-data';
}
&GT;
所以,错误是无论我尝试什么,都没有任何回应。没有错误消息,没有。我尝试了这个链接,它说“无数据”#39; obviesly。
您需要更多详情吗?求你了!
我必须添加一些东西,所以你今天过得怎么样?
HTML在这里,哈哈。为什么我要添加这些好东西:
<div class="setting-row">
<div class="item">
<div class="name">{{ trans('common.name') }}</div>
<input type="text" class="show-input" id="susername" placeholder="{{ trans('common.name') }}" value="{{ getUsername() }}">
</div>
<div class="item">
<div class="name">{{ trans('common.email') }} <span>Disabled</span></div>
<input type="text" class="show-input" id="semail" placeholder="{{ trans('common.email') }}" value="{{ getMail() }}" disabled>
</div>
<div class="item">
<div class="name">{{ trans('common.password') }}</div>
<input type="text" class="show-input" id="spassword" placeholder="New password here">
</div>
<div class="submit">
<button class="submit-clickable">Save Data</button>
</div>
</div>
答案 0 :(得分:0)
更改这些行:
let username = document.getElementById('susername');
let password = document.getElementById('spassword');
为:
username = document.getElementById('susername').value;
password = document.getElementById('spassword').value;
console.log('username: '+username);
console.log('password:'+password);
它应该有用。