Sugestion for improvement: static load of JSON data #67
Comments
hmm you can use JSONP if you don't wanna deal w/ CORS stuff. Can you clarify your proposed method a bit? |
something like: <script src="all-cities-tz-data.js" /> <script src="timezone-js/date.js" /> <script> $(document).ready(function(){ timezoneJS.timezone.parseJsonData( tzData ); }); </script> where all-cities-tz-data.js is an assignment of the node-parse.js generated data to an variable: var tzData = { zones: { .... }; As in symfony2, I can "concatenate" the above 2 js files into one, with its "Assetic" bundle, these 2 js files will finally require only ONE requests. And this request can be fetched from another "origin". I have no experience on JSONP so my suggestion here may not be good enough, this is just for a reference. Simon |
hmm my suggestion would be what you've already had right now, which is pre-processed static data (minified and gzipped) and send everything down as 1 min.js to avoid extra asset loading requests. During the pre-process stage you can embed JSON no problem. |
I see. Thanks for your info. Right now, I couldn't find any "parseJsonData()" like function to call, so I'm using it with an extra "sync" request now. But it has some other errors reported, let me write them in a separate issue. |
hmm have you tried |
Oh I didn't. Thanks for your reminder. Finally I got it work with: timezoneJS.timezone.loadingScheme = timezoneJS.timezone.loadingSchemes.MANUAL_LOAD; timezoneJS.timezone.loadZoneJSONData('/tz/all-tz.json', true); but if I change the above "true" to "false", I got error: |
hmm I'll try to take a look at it. Can u throw in a bug report for it? Did |
I think I'm not going to use loadZoneDataFromObject for now. loadZoneJSONData() now works well for me (with sync=true). Thanks. |
Cool :) Tks |
Thank you :D |
Hi,
I'm trying to use this library in my symfony2 project, where I have TWO virtual hosts, host (A) for the website and host (B) for the static contents like js, css, img.
Since I suppose the timezone json data (generated with node-parse.js) is relatively static, I'd like to put it under host (B). However, since the website is on host (A), I found that either in sync/async mode, it failed to load the json data file. After several struggling, I realized that it is a cross-origin request which is by-default not allowed, unless I set some Apache directive to allow the cross-domain visit.
Also, I found that "processData()" is a private function in the library which is the core for assign the JSON data into your timezone object. If this function can be reached by the user, I can include the json content, and then pass the json structure into this function. This saves me a request.
Maybe only I have such a requirement as I'd like to load timezones for all countries beforehand. Pls consider this. Thanks.
Simon
The text was updated successfully, but these errors were encountered: