Guest User

Untitled

a guest
Mar 30th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function AJAXcall(_data, returnFunction) {
  2.     if (!returnFunction) {
  3.         returnFunction = function(){};
  4.     }
  5.     var req = $.ajax({
  6.         url: "ajax?cacheFucker="+Math.random(),
  7.         type: "POST",
  8.         data : _data,
  9.         xhrFields: { withCredentials: true},
  10.         success: function(data, textStatus, jqXHR) {
  11.             returnFunction(data);
  12.            
  13.             jqXHR.abort();
  14.         },
  15.         error: function (jqXHR, textStatus, errorThrown) {
  16.             returnFunction(false);
  17.            
  18.             jqXHR.abort();
  19.         }
  20.     });
  21. }
  22.  
  23. function loadShit() {
  24.     AJAXcall({action:"onlinePlayers"}, function(json) {
  25.         allOnlinePlayers = $.parseJSON(json);
  26.     });
  27. }
  28.  
  29. setInterval(function() {
  30.     loadShit();
  31. }, 3000);
Add Comment
Please, Sign In to add comment