Sult

Untitled

May 3rd, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.86 KB | None | 0 0
  1. {% if request.session.character_access.CharacterSheet %}
  2. <script>
  3. $(function(){
  4. var refresher = function () {
  5.     $.getJSON( "{% url 'characters:sheet_json' %}", function(obj) {
  6.         refresh_timer = obj.refresh_timer * 1000;
  7.         setTimeout(refresher, refresh_timer);
  8.  
  9.         if (obj.content) {
  10.             // do shit with content and data
  11.             $("#Content").replaceWith("Jeej we got api data:D");
  12.  
  13.             //content will be a dict that you will use like this
  14.             // obj.content.balance = wallet balance
  15.             // obj.content.location = last known character location
  16.             // obj.content.charactername = charactername
  17.             // for corp in obj.content.employment_history
  18.             // corp.name =
  19.             // etc
  20.         }
  21.     });
  22.   };
  23.  
  24.   setTimeout(refresher, 300); // 0.3 seconds
  25. });
  26. </script>
  27. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment