Note that there are some explanatory texts on larger screens.

plurals
  1. PODebugging javascript/jquery: Expecting more source characters
    text
    copied!<p>I am trying to work on a javascript file as a plugin to the jquery ui datepicker. Basically I have a database table representing reservations for a holiday and I people can pick dates out of the datepicker calendar. I am trying to disable selecting any days that have already been booked in a reservation. Here is my javascript file:</p> <pre><code>$(document).ready(function () { $("#checkin").datepicker({ changeMonth: true, changeYear: true, showOtherMonths: true, selectOtherMonths: true, dateFormat: 'DD, d MM, yy', altField: '#date_in', altFormat: 'yy-mm-dd', beforeShowDay: markInvalidDates, onChangeMonthYear: fetchFreeDays, firstDay: 1 // rows starts on Monday }); $("#checkout").datepicker({ changeMonth: true, changeYear: true, showOtherMonths: true, selectOtherMonths: true, dateFormat: 'DD, d MM, yy', altField: '#date_out', altFormat: 'yy-mm-dd', beforeShowDay: highlightDays, onChangeMonthYear: fetchFreeDays, firstDay: 1 // rows starts on Monday }); </code></pre> <p>});</p> <pre><code>var invalidDays = []; function getReservations() { $.ajax({ type: "POST", url: "MullinsBayServices.asmx/GetVerifiedReservations", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", async: "false", success: function(response) { var unvailableDates = response.d; $.each(unvailableDates, function(index, date) { invalidDays.push(date); }); }, failure: function(msg) { $('#output').text(msg); } </code></pre> <p>});</p> <pre><code>function markInvalidDates(date) { getReservations(); dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear(); if ($.inArray(dmy, invalidDays) == -1) { return [true, ""]; } else { return [false,"","Unavailable"]; } </code></pre> <p>}</p> <p>I'm still kind of new to javascript/jquery and can't figure out where I am going wrong here. Assuming that the webservice returns the dates properly serialized in JSON does this right for what I am trying to accomplish?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload