这是包含正在提交的表单的页面。我为具有以下形式的代码加了星标
<html>
<head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="Scripts/homepage.js"></script>
<link rel='stylesheet' href='index.css'>
</head>
<body>
<img src="wc.png" id="wc">
<div id="banner"> <h1> Wolfeboro Connection </h1> </div>
<div id="feed"> <iframe src="feed.html" id="iframefeed"> </iframe> </div>
<div id="footer"> </div>
<div id="accounts"> <table> <tr> <th> Sign In </th> </tr>
<tr> <td> Username </td> <td> <input type="text" name="loginusername"> </td> </tr>
<tr> <td> Password </td> <td> <input type="password" id="loginpassword"> </td> </tr>
<tr> <td> </td> <td> <input type="submit" value="submit"> </td> </tr>
</table>
**<table>
<tr> <th>Sign Up </th> </tr>
<tr> <td>Restaurant Name </td> <td> <input type="text" id="signupusername"> </td> </tr>
<tr> <td> Password </td> <td> <input type="password" id="verifypassword"> </td> </tr>
<tr> <td> Verify Password </td> <td> <input type="password" id="signuppassword">
</td> </tr>
<tr> <td> Phone Number </td> <td> <input type="text" id="phoneNumber"> </td> </tr>
<tr> <td> Email </td> <td> <input type="text" id="email"> </td> </tr>
<tr> <td> </td> <td> <input type="button" value="submit" id="signupsubmit"> </td> </tr>
</table>**
</div>
</body>
</html>
这是我试图提交表单的ajax
$(function () {
$("#signupsubmit").click(function() {
$.ajax({
type: "POST",
url: "signup.php",
data: { name: signupusername, password: signuppassword , phonenumber: phoneNumber ,
email: email }
});
});
});
这是带有php的页面
<?php
$db = new mysqli('localhost', 'root', 'brewster01', 'WolfeboroConnection');
$stmt = $db->stmt_init();
if($stmt->prepare("INSERT INTO users
(BusinessName, Password, Phone, Email) VALUES (?,?, ?, ?)")) {
$stmt->execute();
$stmt->close();
}
else
{
error_log(mysqli_error($db));
}
?>
[04:16:51.977] NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument @ http://code.jquery.com/jquery-1.9.1.min.js:5