1

I am creating a small web application using WordPress. I'm using Ajax to make multiple calls for a reservation system.

I have 4 steps (Get Industry's, Get Consultants in Industry, Get available times of that consultant, and then make reservation.

It works perfectly in Chrome, but then we get to Microsoft Edge (Windows 10).

All three steps are working properly until the last.

//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");
    }
    });
}

The function is not passing the user, or the cName (Consultant)... Which returns on success

    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();
}
TylerH
  • 20,799
  • 66
  • 75
  • 101
  • Can you use a js debugger or a console.log statement before the ajax call in the makeAppointment function to see that the uid and cName are being passed to that function correctly? – JasonB Feb 22 '18 at 05:57
  • I think it's the dataType html that's mucking it up, ref: https://stackoverflow.com/questions/37418955/jquery-ajax-to-load-xml-not-working-in-ie-or-edge any chance you can switch to another response type? return a json object and then use it to populate the content on the browser-side using js. – admcfajn Feb 22 '18 at 06:09
  • So so strange. I had tried a data-type of JSON from the very beginning, and only changed it to HTML while trying to debug. It worked though! The only difference I can say, in terms of Edge, was that prior I didn't authenticate the user - this time I did - which I'm wondering might have "jump-started" the cache since it was receiving new JS code. Thank you JasonB and admcfajn for taking the time out to help. – Derek Hughes Feb 22 '18 at 16:43

0 Answers0