我PHP也是Ajax编程语言的初学者。我做了我的项目,mysqli使用PHPand将一些数据存储到数据库Ajax,不幸的是它没有保存而是验证每个数据。
这是我做的代码段,但没有结果:
<script>
function sendContact() {
var valid;
valid = validateContact();
if (valid) {
$('#Register').click(function (e) {
var username = $('#username').val();
var email = $('#email').val();
var password = $('#password').val();
var password1 = $('#password1').val();
var data = { "username": username, "email": email, "password": password, "password1": password1 };
jQuery.ajax({
data: data,
url: "phpquery/insert_patient.php", // Url to which the request is send
type: "POST", // Type of request to be send, called as method
success: function (data) {
$('#username').val('');
$('#email').val('');
$('#password').val('');
$('#password1').val('');
}
});
});
}
}
function validateContact() {
var valid = true;
$(".demoInputBox").css('background-color', '');
$(".info").html('');
if (!$("#username").val()) {
$("#userName-info").html("(required)");
$("#username").css('background-color', '#FFFFDF');
valid = false;
}
慕盖茨4494581