0

I know there are plenty of questions and answers about this, here for example, but I cant get it to work in my specific situation. I am trying to pass variables to a view with an ajax call, the start and end dates.

    $('input[name="daterange"]').daterangepicker({
    opens: 'left'
}, function(start, end, label) {
    console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
    $.ajax({
        type: "POST",
        url: "/courses/pageviewsbydate/",
        data: {
            'start_date' : start,
            'end_date' : end,
            'csrfmiddlewaretoken' : $("input[name=csrfmiddlewaretoken]").val()
        },
        success: GA_pagesviewsSuccess.bind(this),
        dataType: 'html'
    });
    console.log("got here");
});
Joe
  • 462
  • 6
  • 14
  • You should be able to pass start and end as extra parameters in `GA_pagesviewsSuccess.bind(this, start, end)` – Geuis Aug 12 '18 at 20:40
  • the TypeError is being thrown by moment.min.js, which datrangepicker is using, I dont know why an ajax call would cause the error though. – Joe Aug 12 '18 at 20:54
  • You didn't ask about a typeerror in your question. – Geuis Aug 12 '18 at 21:13

0 Answers0