Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?

I am using the Code Snippets Plugin for WordPress to send a jQuery Ajax request but I keep receiving a

POST https://mywebsite.com/wp-admin/admin-ajax.php 400 (Bad Request)

I have tried what seems to be a thousand ways to formulate the Ajax request following examples from stackoverflow, jQuery forums, WordPress forums, and it goes on. Always with the same error.

Here is what I currently have in my Snippet editor: JavaScript code

var jq = jQuery.noConflict(); // a bunch of code to determine what day is selected on a calendar, this all works up until the ajax call jq(".c-day-content").click(function () {     console.log ("handled the day being picked quite nicely...");         day = jq(this).text();         day = day.replace(/[^0-9]/g,'');         console.log("day=" + day);     bookingStart = bookingStart.concat(day);     //query the db looking for time slots with appointments and returning this array      var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ) ?>';     console.log(ajaxurl);      jq.ajax({         url: ajaxurl,         data: {             action: "retrieveAttendees",             dateSelected: bookingStart //bookingStart is variable that has a string value         },         method: 'POST',         success: function(data, XMLHttpRequest) {             //never been able to make it to here             console.log(JSON.stringify(data));         },         error: function (XMLHttpRequest, textStatus, errorThrown) {             console.log("we failed again: " + JSON.stringify(XMLHttpRequest));             console.log("text status: " + textStatus);             console.log("errorThrown: " + errorThrown)         }     });  

Then my php handler inside the same snippet editor:

function retrieveAttendees_request() { console.log("made it to the ajax request"); // I've never made it here either if ( isset($  _REQUEST)) {     $  bookingDay = $  _REQUEST['dateSelected'];     global $  wpdb;     $  sql = $  wpdb->prepare("select apps.bookingStart, COUNT(*) as booked from wp_amelia_customer_bookings as books inner join wp_amelia_appointments as apps on books.appointmentId = apps.id where apps.bookingStart like %s'%' and apps.status = 'approved' GROUP BY books.appointmentId;", $  bookingDay);     $  result = $  wpdb->get_row($  sql, ARRAY_A);     echo json_encode($  result); }   die(); } add_action('wp_ajax_retrieveAttendees', 'retrieveAttendees_request'); add_action('wp_ajax_nopriv_retrieveAttendees', 'retrieveAttendees_request'); 

I have tried adding the dataType to the Ajax, no luck. Tried adding both dataType and ContentType, no luck. I have no clue as to why I keep getting the same POST 400 Bad Request error. I would appreciate any help and insight.