我正在使用 WordPress 创建一个小型 Web 应用程序。我正在使用 Ajax 对预订系统进行多次调用。
我有 4 个步骤(获取行业、获取行业顾问、获取该顾问的可用时间,然后进行预订。
它在 Chrome 中完美运行,但随后我们进入 Microsoft Edge (Windows 10)。
所有三个步骤都正常工作,直到最后一个。
//Function for Appointment submission
function makeAppointment( uid, day, time, customer, cName, cCategory ) {
$.ajax({
url: ajaxurl + "?action=saveAppointment",
type: 'post',
cache: false,
data: {
user: uid,
customer: customer,
day: day,
time: time,
cName: cName,
cCat: cCategory,
},
dataType: 'html',
success: function(data) {
console.log("Appointment Added!");
var alertMessage;
//Pass the confirmation message to the Alert popup
$('#alert .message').html(data);
//Enable the popup
$('#alert').addClass("on");
},
error: function(data) {
console.log("FAILURE");
}
});
}
该函数未传递用户或 cName(顾问)... 成功返回
function saveAppointment() {
$userID = $_POST['user'];
$customerID = $_POST['customer'];
$consultCat = $_POST['cCat'];
$conName = $_POST['cName'];
$customerArray = array();
array_push($customerArray, $customerID );
$day = str_replace("-", " ", $_POST['day']);
$time = $_POST['time'];
// Set variables
$row = array(
'field_5a7d085c0d0f3' => $day,
'field_5a7d1c9d63b5a' => $time,
'field_5a7d03afbfcbf' => $customerID
);
add_row('field_5a7cfd494890d', $row, 'user_'. $userID);
//Get User ID to send email
$user_info = get_userdata($customerID);
$user_email = $user_info->user_email;
$subject = 'Business Bootcamp Appointment Confirmation for ' . $day . ', 2018 at ' . $time;
$body = 'The email body content';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $user_email, $subject, $body, $headers );
$content.= '<p>Your Free<br/><span class="underlined">' . $consultCat . '</span><br/>Consultation with<br/><span class="underlined">' . $conName . '</span></br>Has Been Booked For:<br/><span class="underlined">' . $day . 'TH @ ' . $time . '</span></p>';
$content.='<p class="smaller">A confirmation email has been sent!';
echo $content;
die();
}