Get Post Data from JQuery Multidatespicker

Discussion in 'PHP' started by makamo66, Dec 31, 2013.

  1. #1
    This is a very basic question. I don't know how to get the post data from the jquery multidatespicker. When I submit the page I want to echo back the post variables but I don't see how they're sent with jquery.
     
    makamo66, Dec 31, 2013 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    PoPSiCLe, Dec 31, 2013 IP
  3. makamo66

    makamo66 Active Member

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    I am using print_r($_POST); to get all of the data submitted.
     
    makamo66, Dec 31, 2013 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    Yes... but how do you trigger the datepicker, how do you collect the POST-data, how do you structure the form... Post some code, man.
     
    PoPSiCLe, Dec 31, 2013 IP
  5. makamo66

    makamo66 Active Member

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    $( "#submit_mdp" ).submit(function( event ) {
      $.ajax({
        url: 'http://beta.opentemp.local/user/dashboard',
        data: $("form#submit_mdp").serialize(),
        type: 'POST',
        'beforeSend': function(xhr, settings) {
          console.log('ABOUT TO SEND');
        },
        'success': function(result, status_code, xhr) {
          console.log('SUCCESS!');
        },
        'complete': function(xhr, text_status) {
          console.log('Done.');
        },
        'error': function (XMLHttpRequest, textStatus, errorThrown) {
    
        alert("Error with ajax Function: "+ textStatus+" "+errorThrown); }
      });
    });
    Code (markup):
     
    makamo66, Dec 31, 2013 IP
  6. makamo66

    makamo66 Active Member

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #6
                    var arr=[];
                    $('#simpliest-usage').multiDatesPicker({onSelect: function(date,e) {
                    var found = jQuery.inArray(date, arr);
                    if (found >= 0) {
                        // Element was found, remove it.
                        arr.splice(found, 1);
                    } else {
                        // Element was not found, add it.
                        arr.push(date);
                    }
                    alert(arr);
                    }});
    Code (markup):
     
    makamo66, Dec 31, 2013 IP