Get Post Data from Jquery Multidatespicker
Moderator: General Moderators
Get Post Data from Jquery Multidatespicker
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.
Re: Get Post Data from Jquery Multidatespicker
jQuery doesn't "send" them - it just helps the user to fill in the form value. The value should be in $_POST as if someone had just typed it into a textbox.
Re: Get Post Data from Jquery Multidatespicker
I am using print_r($_POST); but I don't see anything posted (except the token)
Re: Get Post Data from Jquery Multidatespicker
Then it's not included in the form: maybe not inside the <form>, or not given a name, or not included in the hypothetical AJAX.
What's the HTML and Javascript?
What's the HTML and Javascript?
Re: Get Post Data from Jquery Multidatespicker
Code: Select all
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);
}});
$( "#submit_mdp" ).submit(function( event ) {
$.ajax({
url: 'http://beta.opentemp.local/user/dashboard',
//data: dates,
data: $("form#submit_mdp").serialize(),
type: 'POST',
'beforeSend': function(xhr, settings) {
console.log( $("form#submit_mdp").serialize() );
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: Select all
<div id="simpliest-usage" class="box"></div><br />
<form method="POST" action="http://beta.opentemp.local/user/dashboard" accept-charset="UTF-8" id="submit_mdp"><input name="_token" type="hidden" value="9jlMjOzit5sZBGPkYQfwXwSerdzSnZXYVnEyr9Yx"><input class="mdp_button" type="submit" value="Submit"></form>Re: Get Post Data from Jquery Multidatespicker
The multidatespicker calendar is a modal.
Re: Get Post Data from Jquery Multidatespicker
You aren't sending the dates in your AJAX - the "arr" needs to be included along with the serialized form data, like
resulting in
Code: Select all
data: $("form#submit_mdp").serialize() + "&" + $.param({ dates: arr }, false)Code: Select all
_token=9jlMjOzit5sZBGPkYQfwXwSerdzSnZXYVnEyr9Yx&dates[]=2013-12-31&dates[]=2013-12-30&dates[]=2013-12-29