0

I do an ajax call to test if user is allowed to change the date. based on the ajax result, i either show the datepicker calendar or alert them they are not allowed. The problem I have is that the datepicker calendar is not showing up when the condition is met. The odd thing is, it will show up, if i throw in an alert before the datepicker call. any ideas?

    $.ajax({
        type:"POST",
        data:{'planId' : planId,
             '_token' : token},
        url:"checkStartDate",
        async:false,
        success:function(result){
            
            if (result !== "1"){

               $(datePicker).datepicker({
                    format:'mm/dd/yyyy',
                    }).datepicker("setDate",'now');

            }else{
                 //Not Allowed
            } 
        }

but this works:

if (result !== "1"){
 alert('test');
 $(datePicker).datepicker({
     format:'mm/dd/yyyy',
 }).datepicker("setDate",'now');
Barmar
  • 741,623
  • 53
  • 500
  • 612
bart2puck
  • 2,432
  • 3
  • 27
  • 53

0 Answers0