Hi so here is the script that you would think would work out of the box.
function ajax_away_dates() {
global $wpdb; // this is how you get access to the database
$bookonline = $wpdb->prefix . "book_online";
$dateedit = $_POST['data'];
$date=date("Y-m-d",strtotime($dateedit));
$wpdb->insert(
$bookonline,
array(
'allday' => 1,
'appiontmentdate' => $date
),
array(
'%s',
'%d'
)
);
// $wpdb->query("INSERT INTO $bookonline ('allDay','appiontmentdate') SET ('1','$dateedit')");
print $wpdb->last_query;
return $wpdb->print_error(); /*$whatever += 10;
echo $whatever;
*/
wp_die(); // this is required to terminate immediately and return a proper response
}
and the jquery
function senttocalserver(d){
jQuery.post(
ajaxurl,
{
'action': 'calendaradd',
'data': d
},
function(response){
alert('The server responded: ' + response);
}
);
}
URL encodes like
action=calendaradd&data=2015-12-7
But what happens is it stops after 2015 see below
The server responded: INSERT INTO `zo_book_online` (`allday`, `appiontmentdate`) VALUES ('1', 2015)0
please help
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire