posts - call to jquery ajax failing with 500 error when passing extra data field

admin2025-06-02  0

I have the following jQuery for doing an Ajax call and it works fine:

jQuery(document).ready( function($){
$( "#mystatus" ).change(runMyStatus);

 function runMyStatus() {
  var mystatus = this.value;
  var data = {
        'action': 'bikeride_mystatus_function',
        'mystatus': mystatus,
        // 'rideID' : 123,
        'nonce': frontEndAjax.nonce
    };

   var ajaxRequest = $.ajax({
       url: frontEndAjax.ajaxurl,
       type: "post",
       data: data
   });
   ajaxRequest.done(function(response) {
     alert('Success');
   });
   ajaxRequest.fail(function(jqXHR, textStatus, exception) {
     alert('Error.\n' + jqXHR.status + ' ::' + textStatus + ' ::' + exception);
   });
 } // end runMyStatus
// end document ready
});

If I uncomment the line with rideID then it fails with a "500" status (I tried putting 123 in quotes but it made no difference). If I change the type from "post" to "get" then it works. This error occurs even with no plugins enabled and using the twentyseventeen theme. Any idea what is causing the error?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748821689a314007.html

最新回复(0)