0

I have a jQuery function which redirect to "/schedule" page after adding the task , but I want to redirect that page to a specific date result(TaskDate:

$("#datepicker").data('datepicker').getFormattedDate('yyyy-mm-dd')).


function addTask() {
  $.post("/add-task",
    {
        ProjectID: $("#project").val(),
        TaskDate: $("#datepicker").data('datepicker').getFormattedDate('yyyy-mm-dd'),
        Workers: $("#workers").val(),
        Equipment: $("#equipment").val(),
        Material: $("#material").val(),
        Notes: $("#notes").val()
    }, function (res) {
        if (res == 1) {
           window.location.href = '/schedule';
        } else {
            $("#error").show();
        }
    });
}

If we add the task for 15 December it should shows the list from 15 December to upcoming week . but now it comeback to current week which is "/schedule" page

pankaj
  • 74
  • 2
  • 11

2 Answers2

0

You have to pass desired data as querystring to next page and retrieve it using a server side language (e.g. $_SERVER['QUERY_STRING'] in php) or using pure jquery (this link)

to atatch query string to url just use this:

 window.location.href = '/schedule/?TaskDate=' + TaskDate;
Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82
  • But In url I dont have any querystring when display data or redirect etc.When I select any date from datepicker it shows the list from that date to next week with the same url like www.example.com/schedule. – pankaj Nov 20 '17 at 13:19
0

It solved by assigning the selected date value to current date

pankaj
  • 74
  • 2
  • 11