I don't quite understand how ajax works, esp the "data" on it. I know what to put in url and type but on data I have no idea what to put there and what's is data on AJAX.
I want to fetch data on my database using AJAX, by calling php script using AJAX. I want to get dates that is fully booked and disable it on the datepicker plugin I used.
<script type="text/javascript">
let picker = new Lightpick({
field: document.getElementById('lightpick-datepicker'),
minDate: new Date(),
disableWeekends: true
});
let disabledDates = // here ajax request to fetch unavailable dates as array.
// for example fetch data has returned that array:
// [
// ['2019-02-05', '2019-02-11'],
// ['2019-02-14', '2019-02-16']
// ]
// set to picker unavailable dates
picker.setDisableDates(disabledDates);
</script>
this is my code above and this how I think how this code should work or am i wrong? I just dont know what to put there and how does AJAX works.
If ever someone actually solve/help me on this, Can you please explain oh how calling php script ajax works? because I might use this "calling php script using AJAX" often on my project.
I tried search about this call php script using AJAX thing. But they explain poorly on how it works they only give codes though the codes they give doesn't solve my problem.
Tried this code::
<script type="text/javascript">
let picker = new Lightpick({
field: document.getElementById('lightpick-datepicker'),
minDate: new Date(),
disableWeekends: true
});
let disabledDates = ({
$.ajax({
url: '/action/get_dates.php';
type: 'POST';
data: {} // i dont know that to put here
});
)};
// set to picker unavailable dates
picker.setDisableDates(disabledDates);
</script>
", { "class": "my-new-list", html: items.join( "" ) }).appendTo( "body" ); }); – user3563774 Feb 13 '19 at 14:49