AJAX calendar navigation returns -1

  1. Echo your output in your AJAX callback function
  2. Exit PHP after you echo your output using exit;
  3. Since you’ve localized the ajaxurl variable, use it in your AJAX request
  4. Pass action : ‘my_special_action’ into your AJAX request
  5. Whatever action you use, use the same for both nopriv and normal AJAX hooks

Here’s how your AJAX call should look:

function prevMonthSwap(prevMonthVal,prevYearVal) {
    jQuery("#calendar-container").html("<h1>LOADING</h1>").show();
    jQuery.post(ajaxurl, {action: 'my_special_action', month: prevMonthVal, year: prevYearVal}, function(data){
        jQuery("#calendar-container").html(data).show();
    });
    return false;
}

Here’s how your callback function should end:

function draw_ajax_calendar(){
    //Your other code here
    echo $calendar;
    exit;
}

Here’s what your AJAX hooks should look like:

add_action('wp_ajax_nopriv_my_special_action', 'draw_ajax_calendar');
add_action('wp_ajax_my_special_ajax', 'draw_ajax_calendar');

Not sure what’s going on with your date variables. Shouldn’t you isolate these to a function?

Hope this helps you out.