Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Add async: false into your ajax call so the app will wait for the response before continuing, like so</p> <pre><code>$('#datepicker').focus(function(){ //alert($('#name').html()); $.ajax({ url: 'getDates.php', data: "artist_id="+$('#name').html(), dataType: 'json', async: false, success: function(data) { unavailableDates = data; } }); </code></pre> <p>Another thought, you could possibly add this ajax call right into the unavailable function rather then having two things that run first, onFocus and beforeShowDay (although I'm not terribly familiar with the beforeShowDay function)</p> <p>This may slow down the opening of the date picker though, as it will have to wait for the service so it depends on how fast your service is and what performance requirements you have. Other options if this can be to slow would be to pop up a "getting dates" message or pull the server every X seconds while the page it up (although that could add a lot of extra service calls...)</p> <p>EDIT: After this comment...</p> <pre><code>"basically when user selects an option (here they want to book artists so \ when user selects an artist), the unavailable dates of datepicker are updated automatically." </code></pre> <p>it seems like loading the list when the artist is selected would make more sense, unless your concerned about changes while the page is open. In that case I would do something like...</p> <pre><code>On Artist Changed -Disable date picker, possibly add a small note next to it / under it / over it that it is loading -Start ajax call with async true -In ajax success function, re-enable the picker and remove the message. </code></pre> <p>This will allow the UI to stay active, allow the user to enter other information while the dates load, and if the service is fast enough, the won't even hardly know it was disabled for a second. Your dates won't be quite a "live" as the other way, but it doesn't sound like they need to be that live. You will need to recheck the dates when the form is submitted anyway.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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