Thursday, May 2, 2013

pv app - the issue discovered

Today I found why the loop I made to loop through all the days doesn't work and just increments the days to the max and then starts the requests.  The issue is that the google calendar api and all of its functions are asynchronous so if you put it in a loop it will just run on its own and not according to the loop at all (it will just do its thing).

From reading about this here, https://groups.google.com/forum/?fromgroups=#!topic/google-ajax-search-api/1DxzKw5mzOY, I've found that there's no way to make it synchronous.  The only other solution I've thought of so far was to make the loop wait before making an increment by using the setTimeout method: http://www.w3schools.com/jsref/met_win_settimeout.asp

I've also changed the loop just to work with the day var now rather than I so it's:
for (day = 1; day < 30; day++) {

So will the issue be resolved today?  No, because there's no time left in this period but hopefully everything can be fixed easily tomorrow.

No comments:

Post a Comment