codingOL

need debug

Nov 5th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sendRequest(url, type, onSuccess, onError)
  2.     {
  3.         var httpURL = "http://" + cloudURL + ":" + cloudPRT + "/service" + url;
  4.  
  5.         console.log("Doing " + type + " request on URL " + httpURL);
  6.  
  7.         var response = $.ajax({
  8.             url: httpURL,
  9.             async: true,
  10.             type: type,
  11.             cache: false
  12.         });
  13.  
  14.         response.success(onSuccess);
  15.         response.fail(function (a, b, c)
  16.         {
  17.             onError(b, c);
  18.         });
  19.     }
  20.  
  21.     /****************
  22.     getUserStatVal - parameter - name of the stat (string)
  23.     Currently, 'val' returns undefined even when the stat
  24.     returns properly within the function?
  25.     ****************/
  26.     this.getUserStatVal = function(statName, val)
  27.     {
  28.         var p = {};
  29.        
  30.         // DO NOT CHANGE false
  31.         sendRequest("/stats/user?getstat=" + statName + "&gameid=" + gameId + "&session=" + sessionId +
  32.                     "&all=false", "GET",
  33.                     function (result)
  34.                     {
  35.                         if (result.ResponseType == 0)
  36.                         {
  37.                             p = JSON.parse(result.AdditionalData);
  38.                             console.log(p);
  39.                             console.log("session..." + sessionId);
  40.                             console.log("name... " + p.stat_name);
  41.                             console.log("value... " + p.stat_value);
  42.                            
  43.                             val = p.stat_value;
  44.                         }
  45.                         else
  46.                         {
  47.                             p = JSON.parse(result.AdditionalData);
  48.  
  49.                             console.log("Err");
  50.                             console.log(p)
  51.                         }
  52.                     },
  53.                     function (status, why)
  54.                     {
  55.                         alert("Error in getUserStatVal function: [status=" + status + "] [reason=" + why + "]");
  56.                     });
  57.     }
Advertisement
Add Comment
Please, Sign In to add comment