var owner_name = $('#owner_name').html();
var owner_email = $('#owner_email').html();
var owner_mobile = $('#owner_mobile').html();
var owner_phone = $('#owner_phone').html();
function jobcardCreate() {
$.ajax({
dataType: 'json',
url: './ajax/jobcard-send.php',
type: 'POST',
data: {
owner_name: owner_name,
owner_email: owner_email,
owner_mobile: owner_mobile,
owner_phone: owner_phone,
},
success: function(data) {
}
});
}
jobcard-send.php:
<?php
include("../includes/connection.php");
$owner_name = $_POST['owner_name'];
$owner_email = $_POST['owner_email'];
$owner_mobile = $_POST['owner_mobile'];
$owner_phone = $_POST['owner_phone'];
// Insert new data into users table
$query = " INSERT INTO";
$query .= " owner";
$query .= " (owner_name, owner_email, owner_mobile, owner_phone)";
$query .= " VALUES";
$query .= " ('{$owner_name}', '{$owner_email}', '{$owner_mobile}', '{$owner_phone}')";
echo $owner_name;
echo $query;
$result = mysqli_query($connection, $query);
//Check if there was an error with the query
if ($result) {
echo json_encode(array("status" => "$owner_name"));
} else {
echo "Database query failed, " . mysqli_error($connection) . "";
}
?>
在我工作之后,已经浪费了很多个小时,:/
这是html:
<div class="card-content one-third">
<div class="list-title thin">Owner Contact</div>
<ul class="detail-list">
<li class="button rounded"><a class="list-heading">Name:</a> <a id="owner_name" class="list-result-edit" contenteditable="true"></a></li>
<li class="button rounded"><a class="list-heading">Email:</a> <a id="owner_email" class="list-result-edit" contenteditable="true"></a></li>
<li class="button rounded"><a class="list-heading">Mobile No:</a> <a id="owner_mobile" class="list-result-edit" contenteditable="true"></a></li>
<li class="button rounded"><a class="list-heading">Phone No:</a> <a id="owner_phone" class="list-result-edit" contenteditable="true"></a></li>
</ul>
</div>
答案 0 :(得分:2)
var owner_name = $('#owner_name').html();
和朋友将在脚本运行时获取你的锚的innerHTML,这是页面加载时(因此在用户输入任何内容之前)。< / p>
移动您尝试阅读innerHTML,以便内部 jobcardCreate
函数。